General > Chit-Chat
little puzzle
(1/1)
czerny:
Try to guess first what is the output of this little proggi!
--- Code: ---#define SIZE 5
int size(int s[SIZE])
{
return sizeof(s);
}
int main(int argc, char **argv)
{
int x[SIZE],k,n=SIZE;
k=size(x)+sizeof(n++);
printf("%d\n",k+n);
return 0;
}
--- End code ---
jj2007:
sizeof(n++); is a cheat >:(
Snowman:
Array to pointer decay caught me off guard. At least C++ has references to arrays. ::)
Interesting how n remains 5 after sizeof(n++). I didn't know that.
Navigation
[0] Message Index
Go to full version