Re: strcat strncat and strlen
- From: "Bill Cunningham" <nospam@xxxxxxxxx>
- Date: Mon, 31 Mar 2008 00:59:23 GMT
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.
.
- Follow-Ups:
- Re: strcat strncat and strlen
- From: Gordon Burditt
- Re: strcat strncat and strlen
- From: santosh
- Re: strcat strncat and strlen
- References:
- strcat strncat and strlen
- From: Bill Cunningham
- Re: strcat strncat and strlen
- From: santosh
- strcat strncat and strlen
- Prev by Date: Re: Doubts about pointers
- Next by Date: Re: || putchar(ch == '\177' ? '?' : ch | 0100) == EOF)
- Previous by thread: Re: strcat strncat and strlen
- Next by thread: Re: strcat strncat and strlen
- Index(es):
Relevant Pages
|