Re: strcat strncat and strlen
- From: "Bartc" <bc@xxxxxxxxxx>
- Date: Mon, 31 Mar 2008 10:05:18 GMT
"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.
--
Bart
.
- Follow-Ups:
- Re: strcat strncat and strlen
- From: santosh
- Re: strcat strncat and strlen
- From: Bill Cunningham
- Re: strcat strncat and strlen
- 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
- strcat strncat and strlen
- Prev by Date: Re: Strange bit shifting result with gcc - am I missing something obvious?
- Next by Date: we need some data on line
- Previous by thread: Re: strcat strncat and strlen
- Next by thread: Re: strcat strncat and strlen
- Index(es):
Relevant Pages
|
|