问题描述
1.00E + 00,0.00E + 00,5.70E-01
2.00E + 00,5.00E-04,5.70E-01
3.00E + 00,1.00E-03,5.70E-01
等
但是,仅读取每行的第二个和第三个元素并将其存储到我将值传递给它们的数组中。我找不到代码有什么问题。如果我删除while语句并重复它们下面的行n次,则可以正常工作。有人对此有解决办法吗?在while条件语句中使用fin.good()感到厌倦,并且不起作用。
#include <iostream>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;
int main()
{
string xcord;
string ycord;
string mole;
double m[100],tx[100],ty[100];
int i,k;
k = 0;
fstream fin;
fin.open("argon");
while(!fin.eof())
{
getline(fin,xcord,',');
getline(fin,ycord,mole,'\n');
tx[k] = stod(xcord);
ty[k] = stod(ycord);
m[k] = stod(mole);
k++;
}
for(i=0;i<k;i++)
cout<<xcord<<"\t"<<ycord<<"\t"<<mole<<"\n";
return 0;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)