From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Exploring the printf() function

Exploring the printf() function - C Tutorial

From the course: Complete Guide to C Programming Foundations

Exploring the printf() function

- [Instructor] The C language most likely spawned the printf function, which is used in many other programming languages. This function generates formatted output. Its first or only argument is a formatting string as shown in this exercise file. This text is output. Unlike the puts function, a new line isn't added to this text automatically. The new line escape character here does the job. And there's the text. The power in the printf function lies in the placeholders or conversion specifications found in the formatting string. Here you see the percent D placeholder, corresponding to it is an additional argument, integer variable A. These data types must match, percent D for decimal integer, and integer variable A. Here is the formatted output. This code's printf statement has three placeholders in its formatting string, percent C for character variable CH, percent U for unsigned integer variable X and percent F for floating point value pi. Most editors color code the placeholders…

Contents