Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

another newbie question 1

Status
Not open for further replies.

rezzij

Instructor
Mar 30, 2004
48
US
In VB, there is an easy way to change a numerical value into a string and vice versa. I can't seem to find a c++ equivalent?
What I want to do is include a float variable in a CString in a MessageBox - for example

float m_number1
answer = (m_number1 * 3.141592 );
CString strMessage;
strMessage.Format("The area of your circle is (%d) ." ,answer);
MessageBox(strMessage);

Which doesn't seem to work?
Thanks!!
 
two errors,
1. area of the number is
answer = (m_number1 *m_number1 * 3.141592 );
2. To format correctly a floating point value use %f instead of %d:
strMessage.Format("The area of your circle is (%f) ." ,answer);


Ion Filipski
1c.bmp
 
good eye on the math ! %f was the key, many thanks and a star ....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top