Hi, been looking at the tutorials and it only tells you how to read in charchters, is there a way to ready floats in from a file of numerical data, or if not a way to convert the char data into floating point after reading it in, thanks Neil
Printable View
Hi, been looking at the tutorials and it only tells you how to read in charchters, is there a way to ready floats in from a file of numerical data, or if not a way to convert the char data into floating point after reading it in, thanks Neil
Assuming a file called file.txt that has the following contents (as an example):
This would be all you needed to read that value in a program.Code:3.457
That is for floating point values represented as text in a file. If you are talking about binary data then the process is going to be a bit different.Code:#include <fstream>
...
std::ifstream input("file.txt");
float fValue;
input >> fValue;