C examples for Language Basics:scanf
Modifier | Meaning | Example |
---|---|---|
* | Suppress assignment (see text). | "%*d". |
digit(s) | Sets Maximum field width. Input stops when the maximum field width is reached or when the first whitespace character is encountered, whichever comes first. | "%10s". |
hh | Read an integer as a signed char or unsigned char . | "%hhd" "%hhu". |
ll | Read an integer as a long long or unsigned long long (C99). | "%lld" "%llu". |
h,l , or L | Using L instead of l with e , f , and g indicates that the value will be stored in type long double. In the absence of these modifiers, d , i , o , and x indicate type int , and e , f , and g indicate type float . | "%h" |
j | When followed by an integer specifier, indicates using the intmax_t or uintmax_t type (C99). | "%jd" "%ju". |
z | When followed by an integer specifier, indicates using the type returned by sizeof (C99). | "%zd" "%zo". |
t | When followed by an integer specifier, indicates using the type used to represent the difference between two pointers (C99). | "%td" "%tx". |
Example,