4 ms·
I'd have called it "gotchas" or "puzzlers" instead of "puzzles". It might have been more educational in nature if the OP quotes relevant portions of the C stan
by 0xmohit 10y ago
I'd have called it "gotchas" or "puzzlers" instead of "puzzles".
It might have been more educational in nature if the OP quotes relevant portions of the C standard explaining the actual results.
- ohyoutravel 10y agoThis one, for example. It's just a typo, not really a "puzzle." (apparently I don't know how to write code on hn) #include<stdio.h> int main() { int a=10; switch(a) { case '1': printf("ONE\n"); break; case '2': printf("TWO\n"); break; defa1ut: printf("NONE\n"); } return 0; } If you expect the output of the above program to be NONE, I would request you to check it out!!
- mikeash 10y agoPlace two or more spaces at the beginning of a line to get code formatting. Edit: two, not four. Thanks, jonsen.
- jonsen 10y agoText after a blank line that is indented by two or more spaces is reproduced verbatim. (This is intended for code.)
- fisherjeff 10y agoIt is just a typo. What makes it "puzzling", though, is that it compiles.
- 0xmohit 10y agoIt is just a typo. The compiler considers it to be a label. Perfectly legitimate.
- fisherjeff 10y agoYep. Not particularly baffling in the context of a puzzle, but I could definitely see that as being a pretty fun typo to debug. Although I'd think the syntax highlighting would typically be a little less misleading...