Ive searched everywhere on this form for the last 5 hours for a simple read data file into a 2D array code to follow but none are helpful! So I decided to create an account.
Please could anyone help me with this simple command?
Ive tried this multiple of ways but what I think happens is that the array doesnt know when to stop reading data therefore if the datafile is just 2, 1 3. it reads 2 1 3 3 3 3 !
I have looked up transferring it into string and scanning the input etc but it looks all too complex....
Can anyone just help construct a none complex code?
for (int m= 0; m <1; m++)
for (int n = 0; n < 3; n++)
myInFile >> contents[m][n];// program just keeps reading data, no way to stop it.
cout << contents[m][n] << endl;
cout << "File does not exist." << endl;
myfile >> row >> col;
for(i = 0; i < row; i++)
for(j = 0; j < col; j++ )
myfile >> contents[i][j];
cout << contents[i][j];
THANK YOU VERY MUCH! And im VERY VERY new to C++.. Please try to explain :(