views:

156

answers:

1
std::string s("??<");
std::cout << s << std::endl;

Why does that output { instead of ??<

I'm using Visual Studio 2008. I'm assume it's encoding it but why and what is the encoding called if that is what's happening?

This little %#$^*! caused me to look for a bug in my (unit test) code for 30 minutes before I figured out my string was mangled!! :(

+26  A: 
unwind
that was too easy for you :\ but that looks like the correct answer!!! Thanks!
cchampion
Never heard of those... nice!
xtofl
Looks like ASP uses Digraphs too: `<%` -> `{`, `%>` -> `}`
Ivan Nevostruev
Eh? ASP `<%` is part of its syntax, not a digraph in C/C++ sense. It's not "translated" to `{`. The major problem with C/C++ trigraphs is that they're replaced very early on, before the stream is even tokenized; thus, they're replaced in string literals, comments, etc...
Pavel Minaev