What is the use of format specifier? What is the need for the format specifier? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the use of format specifier? What is the need for the format specifier?

6th Sep 2019, 1:20 PM
Pallavi
4 Answers
+ 11
The format specifier are usually used during input and output in C. It tells the compiler what type of data is in a variable during taking input using scanf() or printing using printf(). To print formatted output or to take formatted input we need format specifiers. If you want an integer variable then use %d, if a characyer then %c and the list continues. List of all format specifiers : https://codeforwin.org/2015/05/list-of-all-format-specifiers-in-c-programming.html
6th Sep 2019, 1:30 PM
Nova
Nova - avatar
+ 2
% notation called format specifier in C. Below are few of them : %c - character - Ex: 'A' %o - octal number (base 8) - Ex: 04 %s - a string of characters - Ex: 'Pallavi ' %d - integer number - Ex: 256 %x - number in hexadecimal (base 16) - Ex: 0x12
6th Sep 2019, 1:54 PM
Kuri
Kuri - avatar
+ 1
Thank you sir!!
6th Sep 2019, 1:33 PM
Pallavi
+ 1
Thank you!!
6th Sep 2019, 2:01 PM
Pallavi