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
This is a discussion on Reading float values from a file?? within the C++ Programming forums, part of the General Programming Boards category; Hi, been looking at the tutorials and it only tells you how to read in charchters, is there a way ...
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;
Last edited by hk_mp5kpdw; 02-23-2005 at 07:50 AM.
I used to be an adventurer like you... then I took an arrow to the knee.