变量周围的2D数组堆栈已损坏

时间:2018-09-21 17:15:12

标签: c++ multidimensional-array visual-studio-2015 compiler-errors

二维数组出现错误“运行时检查失败#2”。

char temp[5][100] = {0};
sprintf_s(temp[1], sizeof(temp), "test");
cout << temp[1] << endl;

但是当索引为零时就没有错误。

char temp[5][100] = {0};
sprintf_s(temp[0], sizeof(temp), "test");
cout << temp[0] << endl;

我确实了解导致此错误的原因。有人可以启发我吗?预先感谢。

0 个答案:

没有答案