No, '\0' do not eliminate the last character in the string. It's the terminating NULL byte. It's the end-character for a string.
What strlen does is counting bytes in the string. It loops through the string, while counting, until it reaches a terminating NULL byte. Even if there's characters after the terminating NULL byte it will not continue.
It's easy to make a function yourself which does the job. This is just my version. IMO, simple and clean.
Code:
unsigned int my_strlen(const char *szString)
{
unsigned int iBytes = 0;
while(*szString++ != '\0')
iBytes++;
return iBytes;
}
And you can test it...
Code:
char buffer[128];
printf("sizeof: %u\n", sizeof(buffer));
printf("strlen: %u\n", strlen(buffer));
printf("my_strlen: %u\n", my_strlen(buffer));
buffer[0] = 'a';
buffer[1] = '\0';
buffer[2] = 'b';
printf("sizeof: %u\n", sizeof(buffer));
printf("strlen: %u\n", strlen(buffer));
printf("my_strlen: %u\n", my_strlen(buffer));