I did this:
int i=1;
sizeof(++i);
cout<<i;
…and the output is 1. Why did the integer not increment in its value?
I know it might be a stupid question, but I didn't know where else to ask/search for the answer.
I did this:
int i=1;
sizeof(++i);
cout<<i;
…and the output is 1. Why did the integer not increment in its value?
I know it might be a stupid question, but I didn't know where else to ask/search for the answer.
sizeof
is determined by the compiler at compile time, and only the type of the argument matters. That's why you can have, e.g.
int *list = malloc(10*sizeof(*list));
Even though list
is uninitialized at the sizeof
.