CString.Format method help? - Programmer

This is a discussion on CString.Format method help? - Programmer ; Hello, I'm looking to convert an integer to a CString (In visual studio 2005). I thought the Format method was the appropriate route, and tried the following code: int i=1; CString test; test.Format("%d",i); However, when I try to build it, ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: CString.Format method help?

  1. CString.Format method help?


    Hello,

    I'm looking to convert an integer to a CString (In visual studio 2005).
    I thought the Format method was the appropriate route, and tried the
    following code:

    int i=1;
    CString test;

    test.Format("%d",i);


    However, when I try to build it, I get the following error:

    1> [
    1> BaseType=wchar_t,
    1> StringTraits=StrTraitMFC_DLL
    1> ]
    1> Types pointed to are unrelated; conversion requires
    reinterpret_cast, C-style cast or function-style cast


    The Format method seems pretty straightforward; where am I going awry?


  2. Re: CString.Format method help?


    "Austin" wrote in message
    news:1158593276.281992.66410@m73g2000cwd.googlegro ups.com...
    >
    > Hello,
    >
    > I'm looking to convert an integer to a CString (In visual studio 2005).
    > I thought the Format method was the appropriate route, and tried the
    > following code:
    >
    > int i=1;
    > CString test;
    >
    > test.Format("%d",i);
    >
    >
    > However, when I try to build it, I get the following error:
    >
    > 1> [
    > 1> BaseType=wchar_t,
    > 1> StringTraits=StrTraitMFC_DLL
    > 1> ]
    > 1> Types pointed to are unrelated; conversion requires
    > reinterpret_cast, C-style cast or function-style cast
    >
    >
    > The Format method seems pretty straightforward; where am I going awry?
    >


    Looks like a Unicode build. Try the following:

    test.Format( _T( "%d" ), i);



+ Reply to Thread