Re: Converting from string to integer, integer to string, string to float, float to string
From: ak (ak_at_workmail.com)
Date: 10/31/04
- Next message: Steve Russell: "Re: Converting from string to integer, integer to string, string to float, float to string"
- Previous message: Nicolae Fieraru: "Converting from string to integer, integer to string, string to float, float to string"
- In reply to: Nicolae Fieraru: "Converting from string to integer, integer to string, string to float, float to string"
- Next in thread: Steve Russell: "Re: Converting from string to integer, integer to string, string to float, float to string"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 31 Oct 2004 23:00:58 +0800
On Mon, 1 Nov 2004 01:21:05 +1100, "Nicolae Fieraru"
<nospam@please.com> wrote:
>Hi All,
>
>How can I perform these conversion functions? I use Visual C++ 6.0 and I
>want to use available libraries, not to go downloading some other ones from
>the web and not to do some myself.
>
>I found myself StrToInt and StrToInt64Ex. How about the other ones?
>
>
>Regards,
>Nicolae
>
// int to str
stringstream ss;
int n = 123;
ss << n;
string s = ss.str();
// str to int
string s = "12";
istringstream is(s);
int n;
is >> n;
// str to float
string s = "1.12";
istringstream is(s);
double d;
is >> d;
// float to str
double floatnumber = 2.013;
ss << floatnumber;
string s = ss.str();
hth/ak
- Next message: Steve Russell: "Re: Converting from string to integer, integer to string, string to float, float to string"
- Previous message: Nicolae Fieraru: "Converting from string to integer, integer to string, string to float, float to string"
- In reply to: Nicolae Fieraru: "Converting from string to integer, integer to string, string to float, float to string"
- Next in thread: Steve Russell: "Re: Converting from string to integer, integer to string, string to float, float to string"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|