hello once again.
i am having a problem, the bottom is an example of a file i want to read.
0 0 50 2
3 0 1 2
12 2 1 0
0 11 2 3
1 0 3 20
1 0 0 0
as you guessed it is matrices
i am storing both matrices (separated by a new line)in separated structures.
eg.
struct matrix_1 {
string number_1;
string row_1;
string col_1;
}data_1;
struct matrix_2 {
string number_2;
string row_2;
string col_2;
}data_2;
i am reading the file line by line so i can have a column count.
eg.
while(!inputfile.eof()){
string t;
getline(inputfile, t);
}
i am having trouble with creating an appropiate loop to ignore the zeros and store an integer when present and its row and column position, into the structure.
therefore for the above example my first structure will store:
50 row and column number
2 row and column number
3 row and column number
1 row and column number
2 row and column number
etc....
i've tried a million and one things already...
any suggestions will worth their vowels in gold.
THANKS in advance.
i am having a problem, the bottom is an example of a file i want to read.
0 0 50 2
3 0 1 2
12 2 1 0
0 11 2 3
1 0 3 20
1 0 0 0
as you guessed it is matrices
i am storing both matrices (separated by a new line)in separated structures.
eg.
struct matrix_1 {
string number_1;
string row_1;
string col_1;
}data_1;
struct matrix_2 {
string number_2;
string row_2;
string col_2;
}data_2;
i am reading the file line by line so i can have a column count.
eg.
while(!inputfile.eof()){
string t;
getline(inputfile, t);
}
i am having trouble with creating an appropiate loop to ignore the zeros and store an integer when present and its row and column position, into the structure.
therefore for the above example my first structure will store:
50 row and column number
2 row and column number
3 row and column number
1 row and column number
2 row and column number
etc....
i've tried a million and one things already...
any suggestions will worth their vowels in gold.
THANKS in advance.