Hi,
Sorry, ltoa is not part of the POSIX standard (but I have got an old book!),
it is a vendor specific extension.
You would have to use one of the c string library functions as suggested to
you by someone before.
You may want to look at the cout functions for precision as well.
Michael
>From: "Michael Codadeen" <jd...@ho...>
>Reply-To: dev...@li...
>To: dev...@li...
>Subject: Re: [Dev-C++] Integer to std::string?
>Date: Fri, 21 Sep 2001 08:57:53 +0000
>
>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
>
>
>_______________________________________________
>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
|