Converting
-
How can I convert a CString, to a char* ? Or what is the CString equivalent of the function isDigit()
-
How can I convert a CString, to a char* ? Or what is the CString equivalent of the function isDigit()
CString myCString("1N3"); char* MyStringPointer = (LPCTSTR)myCString; isdigit(MyStringPointer[0]); // true isdigit(((LPCTSTR)myCString)[1]); // false isdigit(myCstring.GetAt(2)); // true If you want to be ansi/unicode agnostic then use _istdigit. Endless ways. -Erik
-
CString myCString("1N3"); char* MyStringPointer = (LPCTSTR)myCString; isdigit(MyStringPointer[0]); // true isdigit(((LPCTSTR)myCString)[1]); // false isdigit(myCstring.GetAt(2)); // true If you want to be ansi/unicode agnostic then use _istdigit. Endless ways. -Erik
none of those worked on my VCPP, and I have the 3rd service pack. It says cannot convert const char* to char*.
-
none of those worked on my VCPP, and I have the 3rd service pack. It says cannot convert const char* to char*.
Drake, It's best to learn C/C++ before trying to program in MFC. Since all you are doing is checking is digit and not modifying the string, you can put const in front of your char* declaration and the compiler will not complain. const char* strPtr = (LPCTSTR)myCString; -Erik
-
How can I convert a CString, to a char* ? Or what is the CString equivalent of the function isDigit()
See CString::GetBuffer(..). Be sure to call ReleaseBuffer when you're done. -- Alex Marbus www.marbus.net But then again, I could be wrong.
-
How can I convert a CString, to a char* ? Or what is the CString equivalent of the function isDigit()
Hee now than i saw your message.. prev, I got the same problem with the isDigit() function so I got :mad: and create a iIsNum(CString string) function using VC++ ver 6 BOOL iIsNum(CString string) { int strLenght = string.GetLength(); bool _isnum; CString chr; for (int i = 0; i < strLenght ; i++) { chr = string.Mid(i,1); if(chr >= "0" && chr <= "9") _isnum = TRUE; else { _isnum = FALSE; break; // no use search for other char } } return _isnum; } Hope you still can use this function ~~~