I'm trying to count the number of chars in a char array including the space until the end of the string.
The following compiles but doesn't return the correct value, I'm trying to use pointer arithmetic to interate through my array.
int numberOfCharsInArray(char* array) {
int numberOfChars = 0;
while (array++ != '\0') {
numberOfChars++;
}
return numberOfChars;
}
Many thanks.
Obviously I'm trying to get the equivalent of length() from cstring but using a simple char array.
Of course if my original array wasn't null terminated this could cause a very big value to return (I guess).