#define for for(int z=0;z<2;++z)for
in a major header and pissed off my entire team ;)
-------------------------
EDIT: Some non-programmers have asked for an explanation:
The "#define A B" preprocessor directive means "replace all instances of 'A' with 'B'"
So in this example, the first "for" is what should be replaced, and the rest is what it should be replaced with.
So, if someone writes their own for loop:
for(int i=0;i<10;++i){cout<<i;}
The output of this would normally be: 0123456789
But it will be invisibly transformed into a nested loop, which will run their loop twice:
for(int z=0;z<2;++z)for(int i=0;i<10;++i){cout<<i;}
So the output of this would be: 01234567890123456789
And will leave them scratching their heads. Mwuhahaha!!!
Read other answers by Dale Thomas on Quora:
- I wrote a program that could be written in 5 lines of code in 29. When I looked at the 5 liner version, I was like "I would've never been able to write it that way." Is that normal?
- Am I going crazy if I talk to my compiler and OS like a person?
- Are Japanese programmers generally less tech-savvy, skilled and appreciated in their home country compared to programmers in the US or Europe?
from Quora http://ift.tt/2hWljmW
No comments:
Post a Comment