no match for operator << fstream

Hello fellas, i have this short commands what take 2 numbers from a file separated by a space (" "), and i get this error error: no match for 'operator<<' (operand types are 'std::ifstream {aka std::basic_ifstream<char>}' and 'float')| , what should i can do to fix it? thanks in advance!

1
2
3
4
5
6
7
8
int pnv, hmpnv;
ofstream dwnv;
dwnv.open ("RNFS.txt");
while(dwnv >> pnv >> hmpnv)
{
//code
}
dwnv.close();
Last edited on
The error message doesn't seem to match the code.

Note that when using ofstream you should use << because you are writing data to the stream and when using ifstream you should use >> because you are reading data from the stream.
I figured out the problem, i was using ofstream instead of ifstream or fstream also, thanks @Peter87 that was the problem! Thanks! :D
Topic archived. No new replies allowed.