Sanskriti
asked

Expert
Abhay Jajodia answered
Hi Sanskriti,
Good observation — they’re both used in printf, but for different types of data.
%sis used to print a string (a sequence of characters ending with\0)%cis used to print a single character
Here’s an example to make it clear:
char movie[] = "Snowpiercer";
// Prints the full string
printf("The full movie title is: %s\n", movie);
// Prints the 4th character (index 3)
printf("The fourth character is: %c\n", movie[3]);
So if you're printing the entire string, use %s.
If you're just printing one character from that string — like movie[3] — use %c.
If you have more questions, I am here to help.
C
This question was asked as part of the Learn C Programming course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer