|
From: Chad S. <ho...@ho...> - 2000-12-06 18:06:43
|
>From: Gregor Peter <Gre...@dl...> >Reply-To: dev...@li... >To: "dev...@li..." ><dev...@li...> >Subject: [Dev-C++] int to string >Date: Wed, 06 Dec 2000 17:58:23 +0100 > >Read my question and you know that I'am a Neewbe :-) > >How to convert, cast, transform, whatever a int value to a string? > >include <string.h> > >string my1String = "John has"; >string my2String = "apples!"; >int myInt = 6; > >my1stString = my1stString + UNKNOWN_FUNC(myInt) + my2ndString; > >As you guessed I'd like to get: >"John has 6 apples!" How about this instead.. string my1String = "John"; string my2String = "apples"; int myInt = 6; strstream buffer; buffer << my1String << " has " << myInt << " "<< my2String << "!" << endl; cout << buffer.str(); // Output = John has 6 apples! Chad Simmons _____________________________________________________________________________________ Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com |