I
isaac2004
hello i am trying to read an input file into a matrix, i have the
following setup to get the file
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
ifstream file;
string name;
cout << "File name? ";
cin >> name;
file.open(name.c_str());
if (file.fail()) {
cout << "Could not open " << name << ".\n";
return 1;
}
char c;
c = file.get();
while (!file.fail()) {
cout << c;
c = file.get();
}
file.close();
return 0;
}
The first line of the file are values that I want to grab as
variables, but I dont know an east method to do this. Then for the
rest of the file, I would like to store it in a two dimensional array.
How would I do this in C++. Thanks for the help
What I am trying to do is
following setup to get the file
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
ifstream file;
string name;
cout << "File name? ";
cin >> name;
file.open(name.c_str());
if (file.fail()) {
cout << "Could not open " << name << ".\n";
return 1;
}
char c;
c = file.get();
while (!file.fail()) {
cout << c;
c = file.get();
}
file.close();
return 0;
}
The first line of the file are values that I want to grab as
variables, but I dont know an east method to do this. Then for the
rest of the file, I would like to store it in a two dimensional array.
How would I do this in C++. Thanks for the help
What I am trying to do is