int main()
{
int a[10] = { 0,1,2,3,4,5,6,7,8,9 };
int* p = a;
cout << (p == a) << endl;;
p += 1; // it's ok
a += 1; // error!
cout << a << endl;
cout << p << endl;
return 0;
}
p+1不会报错,a+1却出错
...全文
786打赏收藏
数组名称和指针的区别是什么?
#include using namespace std; int main() { int a[10] = { 0,1,2,3,4,5,6,7,8,9 }; int* p = a; cout << (p == a) << endl;; p += 1; // it's ok a += 1; // error! cout << a << endl; cout << p << endl; return 0; } p+1不会报错,a+1却出错