大家看看这是为什么?
程序代码:#include<iostream>
using namespace std;
int main()
{
int (*p)[10];
for (int i = 0; i < 10; i++)
{
(*p)[i] = i;
}
int a[10] = {0}; //如果注释掉这行代码,可以正常运行
// 如果不注释这行代码的话,编译没问题,运行时,它提示已停止工作
cout << *p << endl;
cout << p << endl;
cout << &(*p)[0] << endl;
cout << *p + 1 << endl;
cout << p + 1<< endl;
cout << &(*p)[0] + 1 << endl;
return 0;
}我不太理解 int (*p)[10]里边的这个指针,写个程序测试一下看看,结果出现了下边的问题
问题:
int a[10] = {0}; //如果注释掉这行代码,可以正常运行
// 如果不注释这行代码的话,编译没问题,运行时,它提示已停止工作 ,这是为什么呢 ?
这还是c语言的问题,只是感觉输出时,用cout比printf方便,所以写成这样。






