C’s printf and fprintf(stdout,) are not printing

Output is often buffered by the system. You can call fflush, but sometimes, depending on how the caching works, simply ending the output with a newline is sufficient. So try changing

fprintf(stdout, "STARTED!");

to

fprintf(stdout, "STARTED!\n");

And, if that doesn’t help, to

fprintf(stdout, "STARTED!\n");
fflush(stdout)

(And stderr often isn’t cached, as you want to see errors immediately.)

Finally, you will see output when the program finishes (as things are flushed then), which probably explains the rest of the behaviour.

Leave a Comment