#include
using namespace std;
int main()
{
int pw[26] = {0};
int pr[26] = {0};
cout<<pw[26]<<" "<<pr[26]<<endl;
return 0;
}
输出为什么是下面,都初始化后pw[26]和pr[26]不都应该是0吗?
0 1982559437
Process returned 0 (0x0) execution time : 0.369 s
Press any key to continue.
int pw[26] = {0};最后一个元素应该是pw[25];
pw[26]已经越界,所以数据是随机的。
越界了,你能用的最大下标应该是数组大小-1
int pw[26] = {0}; 这个数组的索引是0-25
是我自己短路了,好搞笑啊!!!
越界了,应该是数组长度-1