tags:

views:

567

answers:

3

I once saw this line of code:

std::cout %lt;%lt; "Hello world!" %lt;%lt; std:: endl;

And am wondering what %lt;%lt; means.

+28  A: 

Looks like "%lt;" is supposed to be escaped for http transmission. Like:

%lt;%lt;

was supposed to be:

<<
sean e
+24  A: 

You must have seen that online. Someone uploaded this line:

std::cout << "Hello world!" << std::endl;

Which was translated to this for output to html:

std::cout &lt;&lt; "Hello world!" &lt;&lt; std::endl;

Because, of course, &lt; is the html entity for <.

Finally, something somewhere decided to change the ampersands to percent signs, possibly as part of a url-encoding scheme.

Joel Coehoorn
Eh... sounds slightly more plausible than my idea. I'll remove mine and defer to your wild guess. ;-)
Shog9
Funny: I was thinking of deleting this one because it's essentially the same as the other two. The main thing is the < to < conversion.
Joel Coehoorn
Clearly more thoroughly thought out than my rush job - do I lose my points if I remove mine?
sean e
@sean e: eventually, yeah (requires the SO team to initiate rep recalc, which they do on semi-random occasions, usually in the dead of night, while lightening crackles high above and Spoelsky cackles madly in the background...)
Shog9
leave it up - often the shorter, more concise answers are more helpful.
Joel Coehoorn
deleting an answer won't lose reps. i've done that some times and kept the points. ... but no guarantee! :)
Johannes Schaub - litb
@Shog9, hold on. Does that mean one may not immediately see points drop, but when they recalc reps, then they see there is a diff somewhere and then they drop points afterwards?
Johannes Schaub - litb
@litb: yup.
Shog9
@litb: if you're hitting your rep cap every day and then some, it's not likely to matter. The recalc will pick up votes given later that otherwise wouldn't have counted. At least, that's what's happened to me so far.
Joel Coehoorn
+1  A: 

My first thought was that maybe you saw code that was using C trigraphs. However, there doesn't appear to be a trigraph for < or >.

The C trigraphs and their single-character equivalents are:

??=  #
??/  \
??'  ^
??(  [
??)  ]
??!  |
??<  {
??>  }
??-  ~
Naaff
But digraphs include percent signs (including <% and %>). Unfortunately there's no digraph using a percent sign and letters.
Max Lybbert