Invalid allocation size: 4294967295 bytes
当运行时,输入学生姓名时,比如zhang san ,中间有个空格键就会弹出错误显示,Invalid allocation size: 4294967295 bytes
如果是zhangsan 则可以正常运行。
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
class Student
{
public:
~Student();
void InputStudent(void);
void OutputStudent(void);
void DeleteStudent(void);
void SearchStudent(void);
void ChangeStudent(void);
void ScortByChinese(void);
void ScortByMath(void);
void ScortByEnglish(void);
void ScortByTotal(void);
private:
Student *St;
int Size;
string Name;
int Age;
int No;
float Score[3];
float Total;
float Ave;
};
Student::~Student()
{
delete(St);
}
void Student::InputStudent(void)
{
int len;
cout << "请输入学生的人数:" ;
cin >> len;
system("cls");
Size = len;
St = new Student[Size];
for(int i = 0;i<len;i++)
{
cout << "请输入第"<<i+1 <<"个学生的姓名:" ;
cin >> St[i].Name;
cout << "请输入第" << i+1 << "个学生的年龄:";
cin >> St[i].Age;
cout << "请输入第" << i+1 << "个学生的学号";
cin >> St[i].No;
cout << "请输入第" << i+1 << "个学生的语文成绩:";
cin >> St[i].Score[0];
cout << "请输入第"<< i+1 << "个学生的数学成绩:";
cin >> St[i].Score[1];
cout << "请输入第"<<i+1 << "个学生的英语成绩:";
cin >> St[i].Score[2];
St[i].Total = St[i].Score[0]+St[i].Score[1] + St[i].Score[2];
St[i].Ave = St[i].Total/3.0f;
system("cls") ;
}
}
下面的代码也不知道需不需要发。
当运行时,输入学生姓名时,比如zhang san ,中间有个空格键就会弹出错误显示,Invalid allocation size: 4294967295 bytes
如果是zhangsan 则可以正常运行。