Re: question about pointer define
- From: "Wonder" <sapience@xxxxxxxxx>
- Date: 8 Sep 2005 11:54:21 -0700
Thanks a lot for your kind reply.
Now the problem goes to the difference between
int (*p)[3];
int *p[3];
int *(p[3]);
As you said, the second and the third are same. You are right, for
both, the *p[i] will give a core dump. However, the first one just give
the values of the elements, even though I didn't initialize anything.
int main()
{
int (*p)[3];
cout << *p[0] << "\t" << *p[1] << "\t" << *p[2] << endl;
cout << &p[0] << "\t" << &p[1] << "\t" << &p[2] << endl;
cout << p[0] << "\t" << p[1] << "\t" << p[2] << endl;
}
The output is:
440 -1869574000 -1869574000
0x6101cf3e 0x6101cf4a 0x6101cf56
0x6101cf3e 0x6101cf4a 0x6101cf56
Another strange thing is the second line and third line are same in
this case.
.
- Follow-Ups:
- Re: question about pointer define
- From: John Bode
- Re: question about pointer define
- References:
- question about pointer define
- From: Wonder
- Re: question about pointer define
- From: John Bode
- question about pointer define
- Prev by Date: Re: offsetof() macro
- Next by Date: Re: question about pointer define
- Previous by thread: Re: question about pointer define
- Next by thread: Re: question about pointer define
- Index(es):
Relevant Pages
|