December 11th, 2012, 12:35 AM
#1
How to convert an float into a std::string?
I am working with a XML serializer.
I wonder if I am creating a text element (xerces)
But the value I am after is a float, how do I convert it into a std::string?
Thanks
Jack
December 11th, 2012, 12:47 AM
#2
Re: How to convert an float into a std::string?
Code:
std::ostringstream ss;
ss << v.x;
std::string buff(ss.str());
Errors here. I've included iostream and using namespace std;
December 11th, 2012, 03:04 AM
#3
Re: How to convert an float into a std::string?
Did you include <string> ?
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
December 11th, 2012, 04:54 AM
#4
Re: How to convert an float into a std::string?
Hi John,
I've included and not included it, but it seems to be of a little differences.
Thanks
Jack
December 11th, 2012, 04:55 AM
#5
Re: How to convert an float into a std::string?
Originally Posted by
lucky6969b
Code:
std::ostringstream ss;
ss << v.x;
std::string buff(ss.str());
Errors here. I've included iostream and using namespace std;
First google hit: http://www.cplusplus.com/reference/s...ostringstream/
On the left side, under 'Reference' you see which header this is defined in.
Cheers, D Drmmr
Please put [code][/code]
tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks