Why are fputc and fputs outputs not immediately noticable?
Solution 1:
Are you looking at the contents of the file while it is still openend? Note the file writes are buffered, so you may not be able to see the data until the stream is closed/flushed.
If that is the case you can try calling fflush(stream)
as the last line in the loop. Or wait until the file is closed, of course.
Also note that if you end your program with Ctrl-C the data may never be written at all!
The difference with stdout
is that this stream is usually line buffered, meaning that the stream is automatically flushed whenever you output a new line character, but ordinary streams are not.