O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using printf

The printf function provides a way to direct output to the screen. The function performs several useful tasks in order to achieve this. Among those tasks is creating a string to be output using a set format given by the programmer, combining it with variables that the programmer wants to display the value of, and finally formatting it for correct output on the screen.

It takes at least one parameter (the format string) and as many more as needed to fill out any variables that are referenced to be replaced within that format string. First take a look at the ability of printf to display a constant string value.

There is a long-standing programming tradition that the very first piece of output code that a budding programmer is introduced ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required