-
February 11th, 2010, 11:15 PM
#1
Static array allocation problem
Consider the following code:
int a = 5;
cout << a << " " << &a;
Obviously "a" prints out 5 and &a prints out the address of a. Now this code:
int * b = new int[2];
cout << b << " " << &b;
I get 2 different memory addresses as expected. However, if I do this:
int c[] = {5,6,7};
cout << c << " " << &c;
I get the exact same memory location. Why are c and &c the exact same address? I'm assuming it has something to do with the static allocation of c and the dynamic allocation of b. Any ideas?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|