Custom Search
CCTV Security Cameras

Another Program With More Output


Load the program wrtmore.cand display it on your monitor for an example of more output and another small but important concept. You will see that there are four program statements in this program, each one being a "printf" function statement. The top line will be executed first then the next, and so on, until the fourth line is complete. The statements are executed in order from top to bottom.

main( )
{
printf("This is a line of text to output.\n");
printf("And this is another ");
printf("line of text.\n\n");
printf("This is the third line.\n"); }

Notice the funny character near the end of the first line, namely the backslash. The backslash is used in the printf statement to indicate a special control character is following. In this case, the "n" indicates that a "newline" is requested. This is an indication to return the cursor to the left side of the monitor and move down one line. It is commonly referred to as a carriage return/line feed. Any place within text that you desire, you can put a newline character and start a new line. You could even put it in the middle of a word and split the word between two lines. The C compiler considers the combination of the backslash and letter n as one character. The exact characters used to indicate a newlin and carriage return are operating system specific. MS-DOS, Unix, 1616/OS and Macintosh may vary one from the other.

A complete description of this program is now possible. The first printf outputs a line of text and returns the carriage. The second printf outputs a line but does not return the carriage so the third line is appended to that of the second, then followed by two carriage returns, resulting in a blank line. Finally the fourth printf outputs a line followed by a carriage return and the program is complete.

Compile and run this program to see if it does what you expect it to do. It would be a good idea at this time for you to experiment by adding additional lines of printout to see if you understand how the statements really work.

 
 
 
 
Copyright © C Programs