|
Prev: prime numbers
Next: Default value for user input
From: hirenshah.05@gmail.com on 26 Sep 2005 15:50 i trids itoa, but it is not compiling. so please tell me how to convert integer to string
From: Artie Gold on 26 Sep 2005 16:11 hirenshah.05(a)gmail.com wrote: > i trids itoa, but it is not compiling. so please tell me how to > convert > integer to string > As you'd know if you'd searched the archives (hint, hint) or read the FAQ (hint, hint) what you want is either sprintf() or (if available) snprintf() for more secure code. HTH, --ag -- Artie Gold -- Austin, Texas http://goldsays.blogspot.com (new post 8/5) http://www.cafepress.com/goldsays "If you have nothing to hide, you're not trying!"
From: BobR on 26 Sep 2005 17:56 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 26 Sep 2005 18:53 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 26 Sep 2005 19:39
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 |