ConsoleApplication2.exe中0x01204001处的第一次机会异常: 0xC0000005:访问冲突读取位置0xCCCCCCCC。
#include "stdafx.h";
#include <iostream>;
using std::cout;
using std::cin;
using std::endl;
int main()
{
char pause;
int Max = 26; // 27 indexes minus 1
char* alpha[] = { "A", "B", "C", "D", "E",
"F", "G", "H", "I", "J", "K",
"L", "M", "N", "O",
"P", "Q", "R", "S", "T",
"U", "V", "W", "X", "Y", "Z" };
//char* alpha(alpha1[26]);
//using for loop to print alphabet
cout << "PRINTING CONTENTS OF ARRAY" << endl;
cout << "===========================" << endl;
for (int i = 0; i <= Max; i++) {
cout << alpha[i];
};
cout << endl;
cout << "\n Enter any key then press enter to continue: ";
cin >> pause;
return 0;
}
答案 0 :(得分:0)
将for循环更改为
for(int i = 0; i < Max; i++) {
cout << alpha[i];
};
你很高兴。您正在索引数组的末尾。数组索引从0开始。所以你需要从0到25。