Schreibmaschiene simulieren
-
tu ich eben nicht ist eine Linux maschine
-
Dann bastel es dir nach
#include <ctime> void warten( unsigned int t) { while( (time(0) - t) <= 1 ) ; } int main() { //... warten(time(0)); }Nicht getestet und schon spät. Also keine Garantie
-
gcc-cris -isystem /var/www/webcomp/devboard-R2_01/target/cris-axis-linux-gnu/include -mlinux -mno-mul-bug-workaround -Wall -Wshadow -O2 -g -c -o testpp.o testpp.c
testpp.c:6:18: ctime: No such file or directory
testpp.c: In functionwarten': testpp.c:10: warning: implicit declaration of functiontime'
make: *** [testpp.o] Error 1
cris-strip testpp.out
cris-strip: testpp.out: No such file or directory
make: *** [strip] Error 1gibt es leider nicht
-
#include <time.h>
-
-
OK das gibt es
es funktioniert aber trozdem nicht
erst mit programmende wird alles auf einmal angezeigt
-
Hier nochmal der ganze quelltext
#include "stdio.h" #include "stdlib.h" #include "unistd.h" #include "string.h" #include "time.h" void warten( unsigned int t) { while( (time(0) - t) <= 1 ) ; } int main(int argc, char *argv[]) { int len=0; int i=0; len = strlen(argv[1]); for(i=0; i<len; i++) { printf("%c",argv[1][i]); warten(time(0)); } return 0; }
-
Und warum nich mit C++ Mitteln?
#include <string> #include <time.h> #include <iostream> void warten( unsigned int t) { while( (time(0) - t) < 1 ) ; } int main(int argc, char *argv[]) { std::string text(argv[1]); for(unsigned int i=0; i<text.size(); ++i) { std::cout<<text[i]; warten(time(0)); } return 0; }
-
Der Text wird erst ausgeben, nach einem Zeilenumbruch oder flush.
fflush(stdout); // C std::cout.flush() // C++
-
Kóyaánasqatsi schrieb:
#include <time.h>Nein,
<time.h>ist kein C++-Header. Besser wäre<ctime>.Überhaupt sind die bisher gezeigten Vorschläge nicht unbedingt optimal, da dieses "aktive Warten" durch die Schleife massiv viel Rechenzeit verbrät.
Aber da das nichts mit Standard-C++ zu tun hat, wäre dieser Thread im Linux-Forum wohl besser aufgehoben.
-
cout geht auf diesen system leider nicht
ich benütze folgendes:
http://foxlx.acmesystems.it/?id=4Ich verwende auch den compilier auf dieser homepage:
http://foxlx.acmesystems.it/?id=200Ich bedanke mich schon mal für alle antworten