I've spent the past two hours search this and other forums for pointers & guidance on how I can read a txt file, line by line, and store them in a 2D array that I can manipulate with other functions and then later save the array back to the text file; with little luck. Hopefully some bright spark can point me in the right direction.
Currently my text file contains data, separated by spaces, that looks like this:
Number1 Number2 Number3
Colour1 Colour2 Colour3
Letter1 Letter2 Letter3
...
The "getting and setting" of the 2D Array needs to be done in a separate function, and I think the array's need to be global because they will later be manipulated by other functions (i.e. add a new row, delete a row, etc.)
I know the start to the function will need to look something like this:
void getAndSetData()
{
fstream file1;
file1.open("1.txt", ios::in);
}
And will contain a nested for loop that will in turn, set the elements in the 2D array 1 by one. However, I'm really at a loss as how to go about this.
Thank you in-advance.