i++ Incremements and Execution Sequence
ט"ז תשרי תשס"ז - October 7, 2006Quiz:
What will the following code print?
int i = 5;
printf("%d ", i++ * i++);
printf("%d\n", i);
Quiz:
What will the following code print?
int i = 5;
printf("%d ", i++ * i++);
printf("%d\n", i);
A common issue in writing C based test tools is the desire to be able to show a user a list of all enums. This, of course, is technically impossible, as the mapping from enum to int is one way only. However, the following trick lets you create a two dimensional character array who's index is the enum (cast to int, to be pedantic) is an index to a string containing the name of the enum.
(more...)
I've been collecting nifty tricks and useful factoids about C, and I think I'll start posting them here.
Look for the first post sometime on Tuesday, with 3-4 posts weekly after that!