-
Something Nasty
I don't think this is a bug, it's bigger than that. There's no question that absolutely nothing is wrong with the code (I think). No idea where to start looking either. I didn't believe it until I looked at this:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int test = 0;
printf("%d\n", &test);
return 0;
}
Running this gives some obscure number, 2293620. Running it with a short instead of an int changed it to 2293622. stdio.h and stdlib.h are just from the standard templates I had.
Any hints for what this is all about? I guess I can describe some tech stuff, if it would help.
-
You are trying to print the address of the int. You must do so with %p (and cast to void*).
If you wish to print the actual, remove the &.
-
Hehehehe. I'm embarrased now.
Can you tell it's been a while? (and I wasn't very experienced in the first place...)
-
And what's wrong with that? 2293620 is a perfectly good address to store an int variable in. 2293622 is aligned a little weird, but since a short is only two bytes long there you go. (Note that &test can't possibly be zero -- &test is the address at which test is stored, not the value of the variable itself.)
-
Homework's done! Thanks so much, I was so worried (like complete panic).