CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    136

    CString Conversions

    Hi,
    Can someone please show me the best way to convert a CString variable which is a string number to a real number, say a double, do some math, say times it by two, and covert the result back to a CString?

    Steve Palmer


  2. #2
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: CString Conversions

    Remember that CString has a (const char *) operator and most of the string
    conversion functions take a ccp as an argument. Also remember that CString
    has a Format member that supports the same specifiers as sprintf.


    CString svalue = "3.141596";
    double dvalue = atof( svalue );
    double dresult = dvalue * 2.0;
    CString answer;
    answer.Format( "result is %.3f", dresult );






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured