Home Forums C Programming MFC: changing int to string

Viewing 2 reply threads
  • Author
    Posts
    • #1928
      sameena
      Participant

      Hi

      Can anyone give guidance on changing a int var to a string for display in AfxMsgBox?

      Thanks

    • #3177
      arun_raj7
      Participant

      You can use any of c functions in c++ or mfc as long as you include the correct headers.
      Also I believe the correct syntax for that would be itoa(VartoShow,&ChatToConvert,10);
      You use the ampersand character to point to the string, you cant automatically put a string into a function parameter in accordance to how c++ conducts itself.

    • #3178
      sameena
      Participant

      Hi Gentlemen
      Thanks for the help. I had tried the itao function but did not provide correct parameters. However this is the solution I came up with:-


      int iNumRecords=400;
      //CString m_sCountText=iNumRecords;
      CString m_MyTex;
      //s.Format(_T("%d"), total);
      m_MyTex.Format(_T("%d"),iNumRecords);

      Apparrently you can do this and other wonderful things with the CString class :)

      Thanks again
      MegaC

Viewing 2 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.