printf - How to display one dot every second in C before quitting the process? -
i trying display ... (three dots), each dot second delay second dot second delay third dot.
i tried
for(int = 0;i < 3;i++) { sleep(1); printf("."); sleep(1); }
but waits 6 seconds , prints 3 dots don't want that. there fix this. want
. second delay . second delay .
but appear
...
try:
#include <stdio.h> #include <unistd.h> int main() { for(int = 0;i < 3;i++) { printf("."); fflush(stdout); sleep(1); } }
printf()
prints stdout
bufferred. flush out buffer after each printf()
.
<< flush;
c++ equivalent this.
Comments
Post a Comment