Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the length of an LPCSTR

Tags:

c++

lpcstr

I'm trying to convert an LPCSTR to an integer using atoi(), and to verify that the conversion occurred successfully I want to count the number of digits in the integer it produced and the original LPCSTR (it should contain nothing but integers)

I'm having a hard time finding a good way to calculate the length of the LPCSTR. So far the only way seems to be just counting until I get to a '/0'

Any suggestions for a better method?

Thanks

like image 319
Zain Rizvi Avatar asked Oct 13 '09 18:10

Zain Rizvi


1 Answers

To find the length (in this case, the number of digits) of an LPCTSTR, you should be using lstrlen() and not strlen(). Source: MSDN

like image 139
MrD Avatar answered Nov 08 '22 02:11

MrD