Answer the question
In order to leave comments, you need to log in
How are the two implementations of strlen() different?
I saw this implementation of strlen:
size_t strlen(char *str) {
return (char*)memchr(str, '\0', -1) - str;
}
size_t strlen(char *str) {
int count = 0;
while(str[count] != '\0'){
++count;
}
return count - 1;
Answer the question
In order to leave comments, you need to log in
But this implementation does not produce correct values.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question