KAISER91
April 27th, 2011, 06:31 PM
I'm absolutely stumped on how to do this.
Basically, I'm supposed to write a function that reads a file ("Sample.txt") into a 2D array and determines the number of entries(rows). The number of entries must be less than or equal to 200.
For a 2D array will this be a correct header to use?
int readfile(double xy[][200], char filename[])
int main()
{
fstream file("Sample.txt", ios::in);
int row = 0;
int col = 0;
file >> row >> col;
cout << "row = " << row << ", col = " << col << endl;
return 0;
}
The "Sample.txt" file reads something like this;
1 3
2 4
3 5
4 8
5 11
Help will be appreciated.
Basically, I'm supposed to write a function that reads a file ("Sample.txt") into a 2D array and determines the number of entries(rows). The number of entries must be less than or equal to 200.
For a 2D array will this be a correct header to use?
int readfile(double xy[][200], char filename[])
int main()
{
fstream file("Sample.txt", ios::in);
int row = 0;
int col = 0;
file >> row >> col;
cout << "row = " << row << ", col = " << col << endl;
return 0;
}
The "Sample.txt" file reads something like this;
1 3
2 4
3 5
4 8
5 11
Help will be appreciated.