|
|
> You are not making any sense. Are you asking why strlen exists? It
> should be obvious, even to you. How else do you find the length of a
> zero terminated string?
C must not count '\0' as being part of a string. This is the simple code
I tried,
int main(void) {
size_t t;
char hello[]="hello world\n";
t=strlen(hello);
printf("%i",hello);
}
The integer returned was 12. When I removed the '\n' from the string
and recompiled 11 was the number returned.
Why in production code would someone want to know the length of a
string? That's what I am asking. Hence my inexperience speaks for itself.
|
|