Re: strcat strncat and strlen
- From: santosh <santosh.k83@xxxxxxxxx>
- Date: Mon, 31 Mar 2008 22:03:00 +0530
Bartc wrote:
"santosh" <santosh.k83@xxxxxxxxx> wrote in message
news:fspevv$2e1$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Bill Cunningham wrote:
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.
It is a part of a C string. However it is not counted by strlen.
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 format for size_t is %zu. If your compiler does not support this
then the next best method is to use %lu and cast it's argument to
unsigned long.
Printing the value of hello instead of t has a bigger effect than
using the wrong format spec.
Oops. Yes, another case of reading what I expected to read I suppose. In
which case the output that the OP mentioned is wrong. I think this
proves finally that the OP *is* a troll.
.
- References:
- strcat strncat and strlen
- From: Bill Cunningham
- Re: strcat strncat and strlen
- From: santosh
- Re: strcat strncat and strlen
- From: Bill Cunningham
- Re: strcat strncat and strlen
- From: santosh
- Re: strcat strncat and strlen
- From: Bartc
- strcat strncat and strlen
- Prev by Date: Re: ?: as an lvalue
- Next by Date: Re: What's the deal with C99?
- Previous by thread: Re: strcat strncat and strlen
- Next by thread: Re: strcat strncat and strlen
- Index(es):
Relevant Pages
|