cvisual-studio-2008trigraphs

Strange behaviour of visual studio 2008 with escape sequence


Regarding C programming language, the descriptions of escape sequence does not resolve the output of following line in visual studio 2008.

char * str = "??/abc";
printf( "%s", str );

it prints only "bc".
Checking the memory pointed by str, we can find that "??/a" is working as "\a"

Searching on google we can't find anything related to "??/" being treated as backslash.


Solution

  • To expand on AProgrammer's comment, C defines a set of trigraphs for people whose keyboards are missing certain characters. These begin with '??', followed by another character. In particular, '??/' is the trigraph for '\'.

    This translation is done very early on in the complilation process, so the compiler just sees '\a'.

    See MSDN