@K Scott Piel wrote a great answer here, but I want to add one important point.
Note that the stdout
stream is usually line-buffered, so to ensure the output is actually printed and not just left sitting in the buffer waiting to be written you must flush the buffer by either ending your printf
statement with a \n
Ex:
printf("hello world\n");
or
printf("hello world");
printf("\n");
or similar, OR you must call fflush(stdout);
after your printf
call.
Ex:
printf("hello world");
fflush(stdout);
Read more here: Why does printf not flush after the call unless a newline is in the format string?