Re: [Dev-C++] Integer to std::string?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Michael C. <jd...@ho...> - 2001-09-21 08:58:00
|
Hi,
Try
---
#include <stdlib.h>
#include <iostream.h>
#include <string>
int main ()
{
int myInt = 5;
string str (ltoa(myInt));
cout << str << endl;
return 0;
}
---
NOTE: I did not write this on DevC++ but on HPUX 10.20.
Michael
>From: "Jason Hardman" <jas...@bt...>
>Reply-To: dev...@li...
>To: "Dev-C++" <dev...@li...>
>Subject: [Dev-C++] Integer to std::string?
>Date: Fri, 21 Sep 2001 04:30:49 +0100
>
>Hi,
>
>I'm a bit rusty in my C++ and I just cannot seem to find a way of
>initialising a std::string with an integer value. While I can write a
>function to do it quite easily I had thought that there was a either a
>standard function or member of string that would do it, but I can't find
>one. I might be missing something with being tired of course. I know in
>future I will want to be doing similar with float's too, and I hope there
>is
>an easy way of doing that. I don't want to have to reinvent the wheel if I
>can avoid it.
>
>I remember with AnsiString in BCB or (or Delphi) would take it as a
>constructor argument, but std::string doesn't seem to have that ability.
>
>Thanx for any help, Jason.
>
>
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
|