load text files into array

hello, i have some question. here is the contents of text file named "xxx.txt"

xxxx xxx x
yyyy yyy y
zzzz zzz z

do you know how to load it into arrays? for example :
xxxx ----> load into x1[1]
xxx ----> x2[1]
x ----> x3[1]

yyyy ----> x1[2]
yyy ----> x2[2]
y ----> x3[2]

If you know how to use file streams it should be quite simple. I have to admit that a multidimensional array seems to be the best bet for this problem since you could then streamline the code to a nested for loop. (Even though I know how bad that is.)
1
2
3
4
5
6
7
8
for (int row = 0; row < num; row++)
{
    for (int col = 0; col < anothernum; col++)
    {
        fstream >> somestring;
        x[row][col] = somestring;
    }
}
Last edited on
Topic archived. No new replies allowed.