我对指针有一点疑问,请帮助我..
void main()
{
int x[10],*px=x,*py;
int i;
py = &x[5], i = py - (px);
cout << "\nThe value of px=x is:" << (int)px << "\n";
cout << "x[0]\t" << (int)x << "\n";
cout << "x[5]\t" << (int)&x[5] << "\n";
cout << "\nThe value of i=py-px is\n";
cout << i;
}
在上面的程序中,你得到'i'的值作为数组(内存)的整数等价除以2(10/2 = 5)的差。为什么不仅仅是差,即10?
提前致谢!!