What is the difference between %c and %s in C
%s and %c are the format specifier in C language. Here format specifier is used to denotes data types with specific symbols. Example for
Here %s is used to print a string like welcome to my blog website. Whereas %c is used to print a single letter such as A letter.
We can understand here with the help of coding
- for %s
#include <stdio.h>
int main()
{
char a[] = "welcome to my blog website";
printf("%s\n", a);
return 0;
}
Output:- welcome to my blog website
2. for %c
#include <stdio.h>
int main()
{
char ch = 'A';
printf("%c\n", ch);
return 0;
}
Output :-A
Important links and learn more:-