Very URGENT : comma-delimeted lines

guyz, it's very urgent, and im starting to get bored from it;
about the parsing matrix...
When entering a new field i need three information : row, column, data.
and i will take them from a txt file in the following format :
row,column,data
row,column,data
row,column,data
.
.
.
etc...

the function is : bool setElement( int row, int col, int data );
how can i read the comma-delimited files line by line in an integer variable;
i mean it should store the data directly as an integer like...
1
2
3
4
5
6
istream file ("test.txt");
int r, c, d;
while( file.good() ) {
"""What should i put here ???? """
setElement( r, c, d );
}
Last edited on
Check the reference section about "getline", which can take an optional delimiter, and stringstreams, which can help convert a string into a number.
Topic archived. No new replies allowed.