16,472
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
string filename;
cout << "Please Enter the filename you want to translate" << endl;
cin >> filename;
const int N = 50/*, M = 40*/;
ifstream readfile;
ofstream writefile;
readfile.open(filename.c_str());
if(readfile.fail())
{
cout << "Cann't open the file" << endl;
exit(1);
}
float fArray[N][N];
string line;
int nindex = 0;
while(getline(readfile, line))
{
writefile << line << "\n";
istringstream istr(line);
for (int i = 0; i < N; ++i)
{
istr >> fArray[nindex][i];
// cout << fArray[nindex][i] << " ";
}
++nindex;
cout << endl;
}
readfile.close();
return 1;
}