Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   How To Convert From double to LPCTSTR (http://www.go4expert.com/forums/convert-double-lpctstr-t3931/)

nutty boy 19Apr2007 05:39

How To Convert From double to LPCTSTR
 
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"

shabbir 19Apr2007 06:47

Re: How To Convert From double to LPCTSTR
 
Simple. Just do the following.
Code:

CString str;
str.Format("%f",pDoc->m_r1);


nutty boy 19Apr2007 17:49

Re: How To Convert From double to LPCTSTR
 
thanks very much it works fine

shabbir 19Apr2007 18:56

Re: How To Convert From double to LPCTSTR
 
Quote:

Originally Posted by nutty boy
thanks very much it works fine

:D


All times are GMT +5.5. The time now is 08:52.