How I can Give a float Variable (number from text file)

Sep 25, 2008 at 9:09pm
How I can Give a float Variable (number from text file)
Hello
i have a text at this path C:\wamp\www\usd_ask.txt
and this file is Just have a number like 3.4087
i wana give this value to a variable
Can you help me?:)
Sep 25, 2008 at 11:34pm
I believe you would use a stringstream:

http://www.cplusplus.com/reference/iostream/stringstream/
Sep 26, 2008 at 12:40am
sorry i cant find what im need
Sep 26, 2008 at 2:00pm
fscanf will work, but that's C not C++. It'll work, but you might want to find the C++ version if you're using C++

http://www.cplusplus.com/reference/clibrary/cstdio/fscanf.html
Sep 26, 2008 at 2:03pm
btw, what firedraco was saying was that you make a stringstream, then use the functions of stringstream to pull in the variable. It's worth doing if you're learning C++ and not just straight C
Sep 26, 2008 at 10:06pm
Hello, really i cant understand the good way to make it....
But look!!
let the float variable is "usdask"
so its
float usdask;
and i wanna give it this number which putted at the text file "3.415";
this is the file link "C:\wamp\www\usd_ask.txt"
How is the code which i can use????
Sep 26, 2008 at 11:10pm
Stringstreams :D
Sep 27, 2008 at 10:36pm
its un work
sorry
Topic archived. No new replies allowed.