Strange behaviour of visual studio 2008 with escape sequence

67 Views Asked by At

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.

1

There are 1 best solutions below

0
Simon B On BEST ANSWER

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