0
CString cs;  // declaring variable
ULONG64 lmonitor64;// declaring variable
CStringA  csat;// declaring CStringA variable

    cs = _T("xyz");// initialize variable
    csat = _T("abc"); // initialize variable
    lmonitor64 = _strtoui64((const char *)cs, NULL, NULL); //error 
    lmonitor64 = _strtoui64((const char *)csat, NULL, NULL); // Complies fine

Hi all, I am not able to cast cstring to const char *, whereas I can cast CStringA. Can any one give me solution hoe to cast CString to const char *?

  • CString is a weird bugger. It may or may not be backed with a `char *`. Give http://stackoverflow.com/questions/859304/convert-cstring-to-const-char a try. – user4581301 Feb 21 '17 at 02:58
  • You cannot *cast* a wide character string to a narrow character string. This is a conversion, and you need to explain, what your destination character encoding should be. This is assuming that the source character encoding is UTF-16LE. If it isn't, you're going to have to tell us, what that is, too. – IInspectable Feb 21 '17 at 10:08
  • Besides, since this question is tagged [tag:c++], you are probably looking for [std::stoull](http://en.cppreference.com/w/cpp/string/basic_string/stoul) anyway. It has overloads for both wide and narrow character strings. – IInspectable Feb 21 '17 at 10:11

0 Answers0