CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Oct 2008
    Posts
    59

    Question Problem when Converting from CString to int

    I am new on Using with dotnet platform. Previously I have Experience on working with VC++ 6.0.
    On this exp, I hav choose VC++.Net for my current Project... By understanding the UNICODE fromats, I was going on right way(Extremely with the helps of CodeGuru team)

    Here I am receiving some Datas from an Extenal PC Board via Serial Port.
    The Data Receiving as ASCII format and I have stored it on a CString FirstData.
    The following codes explains it.
    Code:
    CString FirstData;// already declared and here reads Data from Serial Port
    for(int i=0;i<FirstData.GetLength();i++)
    {
       int ibyte;
       CString ll;
       ll=FirstData.GetAt(i);
       sscanf(ll,"&#37;x",&ibyte)
    }
    Here I wanna convert this CString value ll to an int Hex Format and print it on a file....
    But it is not working here.error Message came as "Cannot convert parameter 1 from CString to const char*.

    Next I have changed sscanf as
    Code:
    _stscanf(ll,_T("%x),&ibyte);
    It has worked...But when I read the data ibyte..it is wrong(some error datas are printed)
    Again I used atoi function--still error values came.
    How do I convert the exact data to an int Format.plz help...
    Last edited by arunkr6; February 10th, 2010 at 04:10 AM.

Tags for this Thread

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