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?

Jack
  • 15,539
  • 54
  • 145
  • 264
  • Read [Why is “\?” an escape sequence in C/C++?](http://stackoverflow.com/questions/19374878/why-is-an-escape-sequence-in-c-c) – Yu Hao Jun 30 '14 at 06:55

2 Answers2

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.

Jayesh Bhoi
  • 22,676
  • 14
  • 57
  • 72
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 \.

Rahul Tripathi
  • 161,154
  • 30
  • 262
  • 319