问题遇到的现象和发生背景
读取数据,程序只能读取epochnum = 0到epochnum = 1000所包含的数据,程序生成解决方案时,无错误,但调试时被中断
问题相关代码,请勿粘贴截图
//OfileRead为结构体
int Oread(OfileRead *epoch,int epochnum)
{
ifstream oifs;
oifs.open("g.txt", ios::_Nocreate);
if (!oifs.is_open())
{
cout << "文件打开失败" << endl;
return -1;
}
cout << "文件打开成功" << endl;
char str[500];
epochnum = 0;
while (1)
{
if (oifs.eof())break;
int k = 0; epoch[epochnum].epochgps = 0;//gps卫星数
oifs.getline(str, 500);
if (strstr(str, "> ") != NULL)
{
sscanf(str, "> %d %d %lf %c ", &(epoch[epochnum].hour), &(epoch[epochnum].min), &(epoch[epochnum].sec), &(epoch[epochnum].flag));
epochnum++;
}
}
oifs.close();
delete[]epoch;
}
运行结果及报错内容
调试时,出现错误如图
点击中断,并设置对时间与epochnum的监视后,结果如下:
我的解答思路和尝试过的方法
解答思路:可能是1000以后的程序存入出错,但不清楚是哪里的问题
尝试运行输出,也只能输出前1000的相关数据,后续数据与程序都无法读入输出