How To Convert From double to LPCTSTR

Discussion in 'MFC' started by nutty boy, Apr 19, 2007.

  1. nutty boy

    nutty boy New Member

    Joined:
    Apr 9, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Hi Guys
    I have wrote a VC++ program using MS_Visual Studio 2005 as single document interface and i difined a variable m_r1 as double,and i want to display the value of this varible on the screen
    so i wrote this code in the On_Draw function of the view class

    pDC->TextOutA(10,20,pDoc->m_r1,10);

    but when i compiled the program i get an error message
    error C2664:'BOOL CDC::TextOutA(int,int,LPCTSTR,int)':cannot convert parameter 3 from 'double' to 'LPCTSTR'

    pls how to overcome this problem and what can i do to display any type of variable on the screen "the only working one is of type CString"
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Simple. Just do the following.
    Code:
    CString str;
    str.Format("%f",pDoc->m_r1);
     
  3. nutty boy

    nutty boy New Member

    Joined:
    Apr 9, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    thanks very much it works fine
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    :D
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice