Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Awesome comment on trigraphs in C:

These let you use the "WTF operator":

  (foo() != ERROR)??!??! cerr << "Error occurred" << endl;


[Language pedant: although it's legal C, the use of cerr and endl and << is more likely to occur in C++!]


<< is C++ only.


<< is the left-shift operator in C, so the OP's code is syntactically valid C.

It ought not to compile though, since it's trying to shift cerr by a string!


Thanks. Sorry. I'm stupid...


"Goddamn operator overloading" -- Rev Wright


Strangest language feature...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: