Is there an equivalent to fscanf in c++?
I need to read a float from an ifstream. In C, it would be something like the following:
In C++, I could use >> maybe. But is there a safer way of doing this? The way I would think of doing it in C++ is:Code:fscanf(file, "%f", &dist);
Is there a better way than this? Or is this pretty standard?Code:float dist; ifstream file; ... ... file >> dist;