0

I was reading this and found the escape \?. What does means exactly this escape? the literal ? inside a string(I still can't see a reason) or is this a BNF grammar rule which I don't know about?

1

2 Answers 2

2

It specifies a literal question mark. see http://en.wikipedia.org/wiki/Digraphs_and_trigraphs

The backslash is used as a marker character to tell the compiler/interpreter that the next character has some special meaning. What that next character means is up to the implementation. For example C-style languages use \n to mean newline and \t to mean tab.

The use of the word "escape" really means to temporarily escape out of parsing the text and into a another mode where the subsequent character is treated differently.

1

It is used in a feature called trigraphs, it specifies a question mark. Using this you can write three-character sequence starting with question marks to substitute another character

From C11

C11 §6.4.4.4 Character constants Section 4

The double-quote " and question-mark ? are representable either by themselves or by the escape sequences \" and \?, respectively, but the single-quote ' and the backslash \ shall be represented, respectively, by the escape sequences \' and \.

2
  • I think you mean C11 edit it I remove downvote (wasn't me, btw)
    – Jack
    Jun 30, 2014 at 6:59
  • 1
    @Jack:- That was a typo. Updated that! Thanks Jun 30, 2014 at 7:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.