MFC中 txt文件中有多行三列数据,怎么存入不同数组,第一行和第二行数据有所不同
部分数据如下,这只是其中一个例子,第三列数据有时候也不总是为0(即没有什么规律),也就是说要把第一行的数据赋值给a,第二行数据赋值给b。然后从第三行及之后的数据分别存在x...
部分数据如下,这只是其中一个例子,第三列数据有时候也不总是为0(即没有什么规律),也就是说要把第一行的数据赋值给a,第二行数据赋值给b。然后从第三行及之后的数据分别存在x[i],y[i],z[i]三个动态数组中之中,我该怎么处理(不要用到rewind)
1
10053
80.00000000 0.00000000 0.00000000
79.99998400 0.04999600 0.00000000
79.99993800 0.09999100 0.00000000
79.99985900 0.14998600 0.00000000
79.99975000 0.19998200 0.00000000
79.99960900 0.24997700 0.00000000
79.99943800 0.29997200 0.00000000
79.99923500 0.34996700 0.00000000
79.99900000 0.39996200 0.00000000
79.99873500 0.44995700 0.00000000
79.99843800 0.49995200 0.00000000
79.99811000 0.54994600 0.00000000
79.99775000 0.59994000 0.00000000
79.99736000 0.64993400 0.00000000
79.99693800 0.69992800 0.00000000
79.99648500 0.74992200 0.00000000
79.99600100 0.79991500 0.00000000
79.99548500 0.84990800 0.00000000
79.99493800 0.89990000 0.00000000
79.99436000 0.94989200 0.00000000
79.99375100 0.99988400 0.00000000
79.99311100 1.04987600 0.00000000
79.99243900 1.09986600 0.00000000
79.99173600 1.14985700 0.00000000
79.99100200 1.19984700 0.00000000
79.99023600 1.24983700 0.00000000
79.98944000 1.29982600 0.00000000
79.98861200 1.34981500 0.00000000
79.98775300 1.39980300 0.00000000
79.98686200 1.44979000 0.00000000
79.98594000 1.49977700 0.00000000
79.98498800 1.54976400 0.00000000
79.98400300 1.59975000 0.00000000
79.98298800 1.64973500 0.00000000
79.98194100 1.69971900 0.00000000
79.98086400 1.74970300 0.00000000
79.97975400 1.79968600 0.00000000
79.97861400 1.84966900 0.00000000
79.97744300 1.89965100 0.00000000
79.97624000 1.94963200 0.00000000
79.97500600 1.99961200 0.00000000
79.97374100 2.04959100 0.00000000
79.97244400 2.09957000 0.00000000
79.97111600 2.14954800 0.00000000
79.96975700 2.19952500 0.00000000
79.96836700 2.24950100 0.00000000
79.96694600 2.29947700 0.00000000
79.96549300 2.34945100 0.00000000
79.96400900 2.39942400 0.00000000
79.96249400 2.44939700 0.00000000
79.96094800 2.49936900 0.00000000 展开
1
10053
80.00000000 0.00000000 0.00000000
79.99998400 0.04999600 0.00000000
79.99993800 0.09999100 0.00000000
79.99985900 0.14998600 0.00000000
79.99975000 0.19998200 0.00000000
79.99960900 0.24997700 0.00000000
79.99943800 0.29997200 0.00000000
79.99923500 0.34996700 0.00000000
79.99900000 0.39996200 0.00000000
79.99873500 0.44995700 0.00000000
79.99843800 0.49995200 0.00000000
79.99811000 0.54994600 0.00000000
79.99775000 0.59994000 0.00000000
79.99736000 0.64993400 0.00000000
79.99693800 0.69992800 0.00000000
79.99648500 0.74992200 0.00000000
79.99600100 0.79991500 0.00000000
79.99548500 0.84990800 0.00000000
79.99493800 0.89990000 0.00000000
79.99436000 0.94989200 0.00000000
79.99375100 0.99988400 0.00000000
79.99311100 1.04987600 0.00000000
79.99243900 1.09986600 0.00000000
79.99173600 1.14985700 0.00000000
79.99100200 1.19984700 0.00000000
79.99023600 1.24983700 0.00000000
79.98944000 1.29982600 0.00000000
79.98861200 1.34981500 0.00000000
79.98775300 1.39980300 0.00000000
79.98686200 1.44979000 0.00000000
79.98594000 1.49977700 0.00000000
79.98498800 1.54976400 0.00000000
79.98400300 1.59975000 0.00000000
79.98298800 1.64973500 0.00000000
79.98194100 1.69971900 0.00000000
79.98086400 1.74970300 0.00000000
79.97975400 1.79968600 0.00000000
79.97861400 1.84966900 0.00000000
79.97744300 1.89965100 0.00000000
79.97624000 1.94963200 0.00000000
79.97500600 1.99961200 0.00000000
79.97374100 2.04959100 0.00000000
79.97244400 2.09957000 0.00000000
79.97111600 2.14954800 0.00000000
79.96975700 2.19952500 0.00000000
79.96836700 2.24950100 0.00000000
79.96694600 2.29947700 0.00000000
79.96549300 2.34945100 0.00000000
79.96400900 2.39942400 0.00000000
79.96249400 2.44939700 0.00000000
79.96094800 2.49936900 0.00000000 展开
1个回答
展开全部
FILE *fp;
int a,b,i;
double x[100],y[100],z[100];
if((fp=fopen("test.txt","r"))==NULL)
{
AfxMessageBox(_T("打开失败"));
}
else
{
fscanf(fp,"%d",&a);
fscanf(fp,"%d",&b);
i=0;
while(0==feof(fp))
{
fscanf(fp,"%lf",&x[i]);
fscanf(fp,"%lf",&y[i]);
fscanf(fp,"%lf",&z[i++]);
if(i>=100)
AfxMessageBox(_T("超出范围"));
}
}
fclose(fp);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询