问题
I am writing a C code which reads from a file and generates an intermediate .c file.
To do so I use fprintf() to print into that intermediate file.
How can I print " ?
回答1:
You can use escape symbol \" For example
puts( "\"This is a sentence in quotes\"" );
or
printf( "Here is a quote %c", '\"' );
or
printf( "Here is a quote %c", '"' );
回答2:
If you just want to print a single " character:
putchar('"');
The " doesn't have to be escaped in a character constant, since character constants are delimited by ', not ". (You can still escape it if you like: '\"'.)
If it's part of some larger chunk of output in a string literal, you need to escape it so it's not treated as the closing " of the literal:
puts("These are \"quotation marks\"\n");
or
printf("%s\n", "These are \"quotation marks\"");
来源:https://stackoverflow.com/questions/25411644/printing-double-quote-in-c