I could use some help. I am trying to read from a file. the file contains this:
1x+1y+1z=5
2x+3y+5z=8
4x+0y+5z=2
I want to store this into a two dimensional array. Rows are 3 and columns will always be 4. I only want to store the integer values, in this case that will be 1 1 1 5 2 3 5 8 4 0 5 2. How can I store this values into the array? This is what I tried to doing but it is not working. Thank you for the help.
int main(){
fstream file;
file.open("matrix.txt", ios::in);
int arr[3][4];
// copy integers into array and display
for (int i = 0; i < 3; i++){
for(int j= 0; j < 4; j++){
file >> arr[i][j];
cout << arr[i][j];
}
}
}
delete [] arrwhenarris not dynamically allocated usingnew[]? Also, this has more to do with trying to convert the string "1x+1y+1z=5" and strings looking like this into an array with 4 elements. This has virtually nothing to do with file reading.