Friday, January 16, 2009

A Program That Does Something

For a much more interesting program, load the program named wrtsome.c and display it on
your monitor. It is the same as the previous program except that it has one executable statement
between the braces.
main( )
{
printf("This is a line of text to output.");
}

The executable statement is another function. Once again, we will not worry about what a
function is, but only how to use this one. In order to output text to the monitor, it is put within
the function parentheses and bounded by quotation marks. The end result is that whatever is
included between the quotation marks will be displayed on the monitor when the program is
run.

Notice the semi-colon ; at the end of the line. C uses a semi-colon as a statement terminator,
so the semi-colon is required as a signal to the compiler that this line is complete. This program
is also executable, so you can compile and run it to see if it does what you think it should. With
some compilers, you may get an error message while compiling, indicating the printf() should
have been declared as an integer. Ignore this for the moment.

Google Search

Custom Search