关于vs2017堆栈被破坏的问题
#include<iostream>
using namespace std;
void ChessBoard_Initialization(int *temp,int rows,int cols) {
for (int i = 0; i <= rows; i++) {
for (int j = 0; j <= cols; j++) {
*(temp + i * cols + j) = 0;
}
}
}
void ChessBoard_Paint(int temp[9][9]) {
for (int i = 0; i <= 9; i++) {
for (int j = 0; j <= 9; j++) {
cout << temp[i][j]<<" ";
}
cout << endl;
}
}
int main() {
int ChessBoard[9][9];
ChessBoard_Initialization(ChessBoard[0],9,9);
ChessBoard_Paint(ChessBoard);
return 0;
}
出现错误:
0x01223E49 处有未经处理的异常(在 Fivechess.exe 中): 堆栈 Cookie 检测代码检测到基于堆栈的缓冲区溢出。
我检查了 没有出现越界的错误呀?