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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -