Why does C’s printf format string have both %c and %s?
I know that %c represents a single character and %s represents a null-terminated string of characters, but wouldn’t the string representation alone be enough?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Probably to distinguish between null terminated string and a character. If they just had
%s, then every single character must also be null terminated.In the above case,
cmust be null terminated. This is my assumption though 🙂