I know the usage of %s
(lowercase s) in printf()
function of C. Recently I found %S
(CAPITAL S) used in printf()
. Can someone explain its usage. I can't find any information regarding this on internet.
%s and string We can print the string using %s format specifier in printf function. It will print the string from the given starting address to the null '\0' character. String name itself the starting address of the string. So, if we give string name it will print the entire string.
In C printf(), %n is a special format specifier which instead of printing something causes printf() to load the variable pointed by the corresponding argument with a value equal to the number of characters that have been printed by printf() before the occurrence of %n.
The f in printf stands for formatted, its used for printing with formatted output.
The format specifier is used during input and output. It is a way to tell the compiler what type of data is in a variable during taking input using scanf() or printing using printf(). Some examples are %c, %d, %f, etc.
An old, non-standard modifier:
S
(Not in C99, but in SUSv2.) Synonym for
ls
. Don't use.
ls
(and therefore S
) means to take a const wchar_t *
instead of a const char *
like s
.
SUSv2 is the The Single UNIX Specification, Version 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With