错误如题,代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
struct name
{
char name_char;
int fi;
};
struct student_info
{
int id;
long student_id;
int class_num;
name cn[1];
};
void main()
{
int len_byte = sizeof(student_info)+25*sizeof(name);
student_info* student = (student_info*) new BYTE(len_byte);
student->id = 11;
student->class_num = 11;
student->student_id = 123434;
for(int i = 0 ; i < 26 ; i ++)
{
student->cn[i].name_char = (char)(i+22);
student->cn[i].fi = i;
}
cout<<"hello C++"<<endl;
delete student;//在执行这个语句的时候VS会抛出异常,
}
错误显示如下:
其原因可能是堆被损坏,这说明 test_other_func_code.exe 中或它所加载的任何 DLL 中有 Bug。
原因也可能是用户在 test_other_func_code.exe 具有焦点时按下了 F12。