Re: INT to STR

From: keanu (usenet_at_keanu.be)
Date: 11/05/03


Date: Wed, 05 Nov 2003 11:06:38 GMT

Marcel wrote in <3fa8d7f0$0$9476$edd6591c@news.versatel.net>:

> The small code underneath is displaying the text 'hello2' as output. I
> supposed it to display hello50. I think i will have to convert the int to
> a string or am i wrong? If so, what is the right command? Sorry i am a
> beginner....
>
> Thanks in advance!
>
> #include <iostream>
> #include <string>
#include <sstream>
template<typename T> std::string toStr(T var) {
    std::ostringstream tmp; tmp << var; return tmp.str();
}
> int main() {
> int red = 50;
> std::string temp = "";
> temp += "hello";
     //temp += red;
       temp += toStr<int>(red);
> std::cout << temp;
> std::cin.get();
> return 0;
> }



Relevant Pages

  • Re: Brian Kernighan, maybe Im not worthy, maybe Im scum
    ... conformant string. ... int repeats, reps; ... ref satisfierLength); ...
    (comp.programming)
  • RE: Controling Modal Dialogs (Solution)
    ... doesn't return until the 'modal' browser returns. ... string varOptions) ... public void DocumentComplete ... int rc = winDisp.Invoke(rgDispId, ref guid, 0, ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Gcc compatible header file
    ... A string collection is a table of zero terminated strings that will grow ... typedef struct _StringCollection StringCollection; ... int; ... bool; ...
    (comp.lang.c)
  • Kernighan and Pikes "Beautiful" Code
    ... conformant string. ... int repeats, reps; ... ref satisfierLength); ...
    (comp.programming)
  • Re: FTP CD command
    ... public const int GENERIC_WRITE = 0x40000000; ... string lpszProxyName, ... public static extern IntPtr InternetConnect ( ... public static extern bool FtpGetCurrentDirectory ( ...
    (microsoft.public.dotnet.languages.vb)