From: hirenshah.05@gmail.com on
i trids itoa, but it is not compiling. so please tell me how to
convert
integer to string

From: BobR on

hirenshah.05(a)gmail.com wrote in message
<1127764245.658692.61930(a)g47g2000cwa.googlegroups.com>...
> i trids itoa, but it is not compiling. so please tell me how to
>convert
>integer to string
>

#include <string> // C++
#include <sstream>

int main(){
int anum(12345);
std::istringstream iss;
iss << anum;
std::string astr( iss.str() );
return 0;
} // main() end

alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/

--
Bob R
POVrookie


From: Chris ( Val ) on

BobR wrote:
> hirenshah.05(a)gmail.com wrote in message
> <1127764245.658692.61930(a)g47g2000cwa.googlegroups.com>...
> > i trids itoa, but it is not compiling. so please tell me how to
> >convert
> >integer to string
> >
>
> #include <string> // C++
> #include <sstream>
>
> int main(){
> int anum(12345);
> std::istringstream iss;

[snip]

Oop's :-)

std::ostringstream iss;

Cheers,
Chris Val

From: BobR on

Chris ( Val ) wrote in message
<1127775215.821344.105550(a)z14g2000cwz.googlegroups.com>...
>
>BobR wrote:
>> hirenshah.05(a)gmail.com wrote in message
>> <1127764245.658692.61930(a)g47g2000cwa.googlegroups.com>...
>> > i trids itoa, but it is not compiling. so please tell me how to
>> >convert
>> >integer to string
>>
>> #include <string> // C++
>> #include <sstream>
>> int main(){
>> int anum(12345);
>> std::istringstream iss;
>[snip]
>
>Oop's :-)
>
> std::ostringstream iss;
>
>Cheers,
>Chris Val

Thanks Chris. Now I gotta go check another post, I probably have him going
in the wrong direction too! <G> (... his *is* supposed to be an
istringstream.)

--
Bob R
POVrookie


From: Chris ( Val ) on

BobR wrote:
> Chris ( Val ) wrote in message
> <1127775215.821344.105550(a)z14g2000cwz.googlegroups.com>...
> >
> >BobR wrote:
> >> hirenshah.05(a)gmail.com wrote in message
> >> <1127764245.658692.61930(a)g47g2000cwa.googlegroups.com>...
> >> > i trids itoa, but it is not compiling. so please tell me how to
> >> >convert
> >> >integer to string
> >>
> >> #include <string> // C++
> >> #include <sstream>
> >> int main(){
> >> int anum(12345);
> >> std::istringstream iss;
> >[snip]
> >
> >Oop's :-)
> >
> > std::ostringstream iss;
> >
> >Cheers,
> >Chris Val
>
> Thanks Chris. Now I gotta go check another post, I probably have him going
> in the wrong direction too! <G> (... his *is* supposed to be an
> istringstream.)

No worries - I should have changed the identifier too :-)

Better make that:

std::ostringstream Oss;

Cheers,
Chris Val

 |  Next  |  Last
Pages: 1 2
Next: What is panic?