Hi.
I found this interview question online, and it really confuses me...
Consider the following code snippet:
Code:
int main(int argc, char* argv[]) {
int x=97;
int y=sizeof(x++);
printf("x is %d\n", x);
return 0;
}
What is the output?
1. x is 97
2. x is 98
3. x is 99
4. run-time error
My guess was 2, but when I compiled and ran the code, I was amazed to find out that this produce "x is 97"!
What's going on here?
*EDIT
Funny thing is when I change the above to this:
Code:
int main(int argc, char* argv[]) {
int x=97;
int y=x++;
printf("x is %d\n", x);
return 0;
}
It produces "x is 98" as expected...