One way or another you'll end up parsing the file line by line.
Look up the ifstream member getline(). The idea is to take 1 line at a time and then read each group of non-whitespace characters into the array. Since you don't know the size of the matrix/file you can loop it like this:
1 2 3 4 5 6 7
textfile.open("numbers.txt");
while(textfile)
{
//getline() here
//then 'for' loop until the parse reaches the end of the columns
//then move the row index then 'continue' the while loop
}
Instead of getline(), the other option is to use textfile >> matrix1[i][j]; like you are except that you'll have to keep checking for the newline character to know when to start a new row. getline() does this automatically for u...
Hey, thanks for the reply.
I looked into getline and decided I'm going to use that.
So far I've developed this code... but I have one question about it. Does C++ support a function called "hasmoretokens()" used in the string tokenizer class? It existed in java which was the language I used in my fundamentals 2 class.
string array1[10];
string temp;
int rows=0; int columns=0;
Alright I guess c++ doesn't really have anything called stringtokenizer, but stringstream seems to be the same thing, I'm going to mess around with that.