How can I print a quotation mark in C?

后端 未结 9 1475
臣服心动
臣服心动 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:22

    Without a backslash, special characters have a natural special meaning. With a backslash they print as they appear.

    \   -   escape the next character
    "   -   start or end of string
    ’   -   start or end a character constant
    %   -   start a format specification
    \\  -   print a backslash
    \"  -   print a double quote
    \’  -   print a single quote
    %%  -   print a percent sign
    

    The statement

    printf("  \"  "); 
    

    will print you the quotes. You can also print these special characters \a, \b, \f, \n, \r, \t and \v with a (slash) preceeding it.

提交回复
热议问题