จดไว้กันลืม
ref : wiki, cplusplus
d , i | Print an int as a signed decimal number. '%d ' and '%i ' are synonymous for output, but are different when used with scanf() for input. |
u | Print decimal unsigned int . (short) // can print unsigned char as well |
f , F | Print a double in normal (fixed-point) notation. 'f' and 'F' only differs in how the strings for an infinite number or NaN are printed ('inf', 'infinity' and 'nan' for 'f', 'INF', 'INFINITY' and 'NAN' for 'F'). |
e , E | Print a double value in standard form ([-]d.ddd e[+/-]ddd).An E conversion uses the letter E (rather than e) to introduce the exponent. The exponent always contains at least two digits; if the value is zero, the exponent is 00. |
g , G | Print a double in either normal or exponential notation, whichever is more appropriate for its magnitude. 'g' uses lower-case letters, 'G' uses upper-case letters. This type differs slightly from fixed-point notation in that insignificant zeroes to the right of the decimal point are not included. Also, the decimal point is not included on whole numbers. |
x , X | Print an unsigned int as a hexadecimal number. 'x' uses lower-case letters and 'X' uses upper-case. |
o | Print an unsigned int in octal. |
s | Print a character string. |
c | Print a char (character). |
p | Print a void * (pointer to void) in an implementation-defined format. |
Name | Description | Size* | Range* |
---|---|---|---|
char | Character or small integer. | 1byte | signed: -128 to 127 unsigned: 0 to 255 |
short int ( short ) | Short Integer. | 2bytes | signed: -32768 to 32767 unsigned: 0 to 65535 |
int | Integer. | 4bytes | signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 |
long int ( long ) | Long integer. | 4bytes | signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 |
bool | Boolean value. It can take one of two values: true or false. | 1byte | true or false |
float | Floating point number. | 4bytes | +/- 3.4e +/- 38 (~7 digits) |
double | Double precision floating point number. | 8bytes | +/- 1.7e +/- 308 (~15 digits) |
long double | Long double precision floating point number. | 8bytes | +/- 1.7e +/- 308 (~15 digits) |
wchar_t | Wide character. | 2 or 4 bytes | 1 wide character |
ref : wiki, cplusplus
ความคิดเห็น