8 votes
Accepted
How to calculate len size from unsigned char* in C++20?
Yes, unsigned char, signed char, and char are all exactly one byte large, so s.size() gets you the size in bytes of your string. The subsequent two lines are unnecessary, and it's also worth noting ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
strlen × 709c × 372
php × 191
string × 152
c++ × 99
c-strings × 72
arrays × 71
sizeof × 38
pointers × 32
char × 30
assembly × 26
segmentation-fault × 25
malloc × 23
substr × 19
fgets × 18
string-length × 18
printf × 15
for-loop × 14
strcmp × 13
function × 11
if-statement × 11
strcpy × 11
x86 × 9
null × 9
scanf × 8