twitter
    Find out what I'm doing, Follow Me :)

The "Putc" Function

The part of the program we are interested in is the "putc" function. It outputs one character at a time, the character being the first argument in the parentheses and the file pointer being the second and last argument. Why the designer of C made the pointer first in the "fprintf" function, and last in the "putc" function is a good question for which there may be no answer. It seems like this would have been a good place to have used some consistency.

When the textline "others" is exhausted, a newline is needed because a newline was not included in the definition above. A single "putc" is then executed which outputs the "\n" character to return the carriage and do a linefeed.
When the outer loop has been executed ten times, the program closes the file and terminates.

Compile and run this program but once again there will be no output to the monitor.

Following execution of the program, "type" the file named TENLINES.TXT and you will see that the 10 new lines were added to the end of the 10 that already existed. If you run it again, yet another 10 lines will be added. Once again, do not erase this file because we are still not finished with it.