|
-
May 16th, 2007, 01:47 PM
#1
integer to std::string
Hi!
Does anyone know how to "write" a integer into a std::string?
Thank you very much for your time!
-
May 16th, 2007, 01:55 PM
#2
Re: integer to std::string
use a strstream and just "<<" it....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
May 16th, 2007, 01:59 PM
#3
Re: integer to std::string
1) see the FAQ : http://www.codeguru.com/forum/showthread.php?t=231056
2) strstream ... isn't that deprecated ?
-
May 16th, 2007, 01:59 PM
#4
Re: integer to std::string
I got it. Thanks TheCPUWizard.
By the way, this is the function:
std::string CCLInformationColladaFile::IntegerToString(int i) {
std: stringstream o;
if (!(o << i)) return "ERROR";
return o.str();
}
-
May 16th, 2007, 02:29 PM
#5
Re: integer to std::string
 Originally Posted by Philip Nicoletti
2) strstream ... isn't that deprecated ?
Not to the best of my knowledge...where did you here of the possibility????
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
May 16th, 2007, 02:39 PM
#6
Re: integer to std::string
I thought that it was already deprecated (in C++ 98)
Somewhere in Annex D ... I do not have a copy of the
standard on this computer.
-
May 16th, 2007, 02:47 PM
#7
Re: integer to std::string
There is mention of it even in the draft... http://anubis.dkuug.dk/jtc1/sc22/open/n2356/
Have to look into the final when I get back to the office....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
May 16th, 2007, 02:50 PM
#8
Re: integer to std::string
http://msdn2.microsoft.com/en-us/lib...f4(VS.80).aspx
The classes in <strstream> are deprecated. Consider using the classes in <sstream> instead.
-
May 16th, 2007, 02:53 PM
#9
Re: integer to std::string
Thanks a lot.
I will try to change it.
-
May 16th, 2007, 03:44 PM
#10
Re: integer to std::string
 Originally Posted by riruilo
Thanks a lot.
I will try to change it.
The code you posted already uses stringstream (which
is not deprecated).
-
May 16th, 2007, 03:50 PM
#11
Re: integer to std::string
 Originally Posted by Philip Nicoletti
The code you posted already uses stringstream (whichis not deprecated).
No, his post is using the "smiley stream" class.. std: stringstream
It is for generating "embarassing" output...
Last edited by TheCPUWizard; May 16th, 2007 at 03:52 PM.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
May 16th, 2007, 07:59 PM
#12
Re: integer to std::string
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
|