Printing Text

If you were to compile and run the template.c example (written in the previous section), it should work, but it won't do much. To take this up one notch, you'll have the application print a message when it's run. This example will teach you how to create a simple Hello, world! program, a staple of any programming text.

To print text in C, use the printf() function:

printf("I could catch a monkey.");

The printf() function is a printing function with formatting capability (hence, the f). Throughout the rest of the book, beginning with Chapter 3, “Working with Numbers,” you'll see how to format text with printf(), but for the time being, it will be used in its most basic way.

Before getting into an example, you should revisit the ...

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.