I can’t figure out how to display something (like hello world) in every 3 seconds.
I’m writing in only C programming with gcc compiler in linux.
We can stop it by Ctrl+c.
I just want simplest and easiest way to manipulate thet code with my project.
Thank you so much in advance!
You may run into a problem in that standard output is normally buffered, which means that the implementation batches up output until it’s convenient to write it. If you’re writing out every three seconds (and
sleep(3)is a good way to do that), and it’s not showing up every three seconds, try putting infflush(stdout);or writing to the standard error output with `fprintf(stderr, “something\n”);.