Wednesday, January 4, 2012

How do we use printf() to display double quotes?

Because double quotes are special symbols that could be misinterpreted if used alone within a string literal, we must put a backslash immediately in front of them to display them on the screen. No space is allowed between the backslash and the double quotes following it. Thus, the statement

printf("Print 3 double quotes -\" \" \" \n");

produces the following output:

Print 3 double quotes -" " "

No comments:

Post a Comment