How can I print a quotation mark in C?

后端 未结 9 1487
臣服心动
臣服心动 2020-11-29 04:38

In an interview I was asked

Print a quotation mark using the printf() function

I was overwhelmed. Even in their off

9条回答
  •  一向
    一向 (楼主)
    2020-11-29 05:21

    Besides escaping the character, you can also use the format %c, and use the character literal for a quotation mark.

    printf("And I quote, %cThis is a quote.%c\n", '"', '"');
    

提交回复
热议问题