To: | erlug@xxxxxxxxxxxxxx |
---|---|
Subject: | Re: [Erlug] C++ |
From: | "Ivan Sergio Borgonovo" <mail@xxxxxxxxxxxxxxx> |
Date: | Sat, 9 Mar 2002 20:07:32 +0100 |
On 9 Mar 2002 at 16:54, WolfMan wrote: > Ciao a tutti, forse è un pò OT, ma in C++ come si fa a trasformare un > numero in una stringa? > Non un numero in un carattere. > Sono riuscito a fare il contrario cioè una stringa in un numero con le > funzioni atol() atof() atoi(), che però in questo caso non mi serve maniera molto C++/osa e non C/osa atol() e compari sono C/osi guardati sstream #include <iostream> #include <sstream> using namespace std; int main() { int a; string s = "127"; istringstream string_ina(s); string_ina >> a; //yeah cool, isn't it? cout << a << endl; //so you can check return 0; } Ovviamente non mi sono degnato di compilarlo. OKKIO alla gestione degli errori... Come tutte le sante belle cose del C++ istringstream ha un sacco di metodi e proprieties... BASTA CHE PROMETTI E GIURI di non usare mai roba tipo CStringArray ;) ^^^^^^^^^^^^ Questa raccomandazione rende il post non-OT! -- Salve Ivan Sergio Borgonovo http://www.webthatworks.it/ |
<Prev in Thread] | Current Thread | [Next in Thread> |
---|---|---|
|
Previous by Date: | Re: [Erlug] bash, Maurizio Lemmo - Tannoiser |
---|---|
Next by Date: | Re: [Erlug] bash, Ivan Sergio Borgonovo |
Previous by Thread: | Re: [Erlug] bash (precisazione), Nando Santagata |
Next by Thread: | R: [Erlug] C++, wildwolf |
Indexes: | [Date] [Thread] [Top] [All Lists] |