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
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 08:50 AM.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens