永发信息网

C++程序运行后 出现对话框错误 提示 Unhandle exception in XX . exe (神马神马.DLL):M VC exception

答案:2  悬赏:50  手机版
解决时间 2021-02-13 23:01
  • 提问者网友:杀生予夺
  • 2021-02-13 05:27
代码如下:
#include
#include
#include

using namespace std;

ifstream inData;
ofstream outData;

string Answerstd;
string Answer;

void Checktheanswer(ifstream&,ofstream&,string&,string&);

int main ()
{
inData.open("exams.dat");
outData.open("scores.dat");
string Num;
inData>>Answerstd;
inData>>Num;
inData>>Answer;

Checktheanswer(inData,outData,Num,Answer);
outData.close();

return 0;
}
//*****************************************************************************************************
void Checktheanswer(ifstream& inData,ofstream& outData,string& Num,string& Answer)
{
while(inData)
{
if (Answer.length()==Answerstd.length())
{
int T; //计读取的次数
int I; //计答案的个数
int Mark; //成绩
T=0;
I=0;
Mark=0;
while (T<=4)
{
Mark=0;
I=0;
while (I<=20)
{
if (Answer.substr(I,1)!="a"&&Answer.substr(I,1)!="b"&&Answer.substr(I,1)!="c"&&Answer.substr(I,1)!="d"&&Answer.substr(I,1)!="e"&&Answer.substr(I,1)!="f")
{
cout<<"The answer is illigal,it must be a-f and All of them must be 20"<
}
else if (Answer.substr(I,1)==Answerstd.substr(I,1))
Mark=Mark+1;

I++;
}
outData< inData>>Num;
inData>>Answer;

T++;
}

}
else
cout<<"The length of the answer is not correct !"<
inData>>Num;
inData>>Answer;
}

}

一个读取文件中学生答案与标准答案比对的程序,不放数据文件时一切正常,一放就出那个错误,另 学号 也就是NUM变量要读取的是一个7位的号码
求高人指点 非常急!在线等结果 谢谢
最佳答案
  • 五星知识达人网友:鸽屿
  • 2021-02-13 06:12
我使用一个存有12.0
16.0
11.4
的xls文件调式该程序是对的啊。当然我吧string 定义的Answerstd;Num;,Answer 改为指针了。
全部回答
  • 1楼网友:白昼之月
  • 2021-02-13 06:58
看标题好像中毒了,杀毒试试! 再看看别人怎么说的。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯