我需要执行以下操作:
假设 C++ 数组
int fib[] = { 0, 1, 1, 2, 3, 5, 8, 13, 21 };
存储在 32 位机器上,内存地址为 0xA0000000(十六进制)。以下表达式的值是什么?
fib
*fib
&fib[0]
&fib[6]
*(fib+7)
我尝试编写此代码以尝试打印出所需的值。
int main()
{
int i = 0;
int *p = &A0000000;
cout << "i= " << i << endl;
cout << "p= " << p << endl;
*p = 0;
cout << "i=" << i << endl;
int &r = i;
r = 0;
cout << "i= " << i << endl;
int fib[] = { 0, 1, 1, 2, 3, 5, 8, 13, 21 };
cout << "fib= " << fib << endl;
cout << "*(*fib)= " << *fib << endl;
cout << "&fib[0]= " << &fib[0] << endl;
cout << "*(fib+7)= " << *(fib+7) << endl;
cout << "&fib[6]= " << &fib[6] << endl;
system("PAUSE");
return 0;
}
我收到以下错误消息:
c:\users\inquirer\documents\visual studio 2010\projects\fib1\fib1\fib1.cpp(7): error C2065: 'A0000000' : undeclared identifier
预先感谢您的帮助。我需要做什么才能打印出正确的值?