926 B
926 B
The function printf
is the standard way in C to write something to the standard output.
You can just print out a string, but more often then not you want to augment your string with text or numbers determine at runtime.
For that printf has placeholders. When you write % into your string, printf expects you to pass in an argument, to replace the %. Unfortunately writing % isn't enough you also have to specify the type of the argument. To tell printf what kind of argument to expect, you have to write a letter after the %.
- s for an nullterminated string. If it is not nullterminated your program could crash.
- c for a single character
- d for an signed integer
- u for an unsigned integer
- f for floating point numbers
This is not a complete list. You also can specify some formatting options. If you are on a linux system you can use man printf to get all the options or you can simply use google.