Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is use of %S (uppercase s) in printf()?

Tags:

c

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.

like image 430
Ravi Raj Avatar asked Feb 02 '20 12:02

Ravi Raj


People also ask

What is %s in printf?

%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.

What is use of %n in printf in C?

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.

What is %f in printf?

The f in printf stands for formatted, its used for printing with formatted output.

What is the use of S format specifier explain with example?

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.


1 Answers

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.

like image 54
Acorn Avatar answered Sep 19 '22 07:09

Acorn