Format specifiers are used for input and output (I/O) operations. Through format specifiers, the compiler can understand the data types used in I/O operations.
There are some elements that affect format specifiers. They are as follows:
Minus sign (-): Left aligned. The number after
% specifies the minimum field width. If the string length is less than the width, it will be padded with spaces.
Period (.): Separates field width and precision.
The following is a list of some format specifiers:
Specifiers | Use |
---|---|
Single character | |
String | |
Short integer (signed) | |
Short (unsigned) | |
Long double floating point number | |
Do not print anything | |
Decimal integer (default is decimal) | |
Decimal integer (automatically detect base) | |
Octal integer | |
Hexadecimal integer | |
Address (or pointer) | |
Floating point number | |
Unsigned decimal integer | |
Scientific notation The floating point number represented by | |
The floating point number represented by scientific notation | |
Percent sign |
Demonstration
#include <stdio.h> int main() { int num = 31; printf("%o</p><p>", num); return 0; }
Output
37
The above is the detailed content of What are the different format specifiers used in C language?. For more information, please follow other related articles on the PHP Chinese website!