.length() equivalent for char array

I have a char myArray[8] that I'm passing to a function. In my function I need to capture the length of the array similar to how length() returns the number of chars in a string. Is there a function out there that will do the job?

Thanks,
Return 0;
Do you need to know the size of the array (how many characters you can write without producing a segmentation fault) or the size of the string?
For the latter, you can use int strlen(char*) defined in string.h (cstring for C++).
For the former, you'll have to pass the known size. There's no way to determine the size of an array from its pointer (unless it's a static array, and only under certain conditions).
int strlen(char*) was exactly what I was looking for. Thanks!

Topic archived. No new replies allowed.