skipping whitespace with istream
hello,
i have a matrix, and i need to save its contents to a file, and then load it back from the file.
i have the following code:
Code:
template<class T>
void Matrix<T>::write(ostream& os) const {
for(int i=0;i<line;i++){
for(int j=0;j<col;j++){
os << data[i][j] << " ";
}
}
}
template<class T>
void Matrix<T>::read(istream& is) {
for(int i=0;i<line;i++){
for(int j=0;j<col;j++){
is >> data[i][j];
}
}
}
so my file should look like this for example: 1 2 3 4 5
when i'm trying to load it back its not working, so i was thinking that maybe the whitespace characters are messing it up.. so how do i ignore them in the read function?
thanks.
A.