Dan Gookin demonstrates how the printf() function's conversion specifications affect output. Numbers can be formatted to fix a certain width, set justification, and expressed in scientific notation.
- [Instructor] Perhaps the best way to understand the … various width options for the … printf functions placeholders, … is to run some samples in code. … This code outputs integer value one, two, three, … using a clutch of different width formats. … First at line eight comes the default placeholder %d. … No width is specified. … Lines 10 through 12 use eight as the width, … and increase the value displayed for each printf statement. … So line 11 it's a*10, … line 12 it's a*100. … Lines 14 through 16 duplicate these values, … but left justified the output. … See the minus sign … at lines 14 through 16? … Finally, a zero is added to the widths specifier … at lines 18 through 20. … Which pads zero's to the left of the number, … filling the width of eight places. … Build and run. … Behold, … the effect of all the conversion specifications … on the values. … In this exercise file, … you see the %f placeholder with some width … and truncation options. … Line eight specifies no width. … Line 10 specifies a width of 15 characters. …
- Working with arrays
- Building a structure
- Creating an array of structures
- Testing characters
- Working with strings in C
- Using pointers to manipulate data
- Manipulating files
- Using command-line arguments
- Working with time functions
Skill Level Intermediate
1. Arrays and Structures
2. Characters and Strings
4. Files and the Operating System
5. The Interesting and Extraordinary
Next steps1m 52s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.