comp.lang.c
[Top] [All Lists]

Re: strcat strncat and strlen

Subject: Re: strcat strncat and strlen
From: santosh
Date: Mon, 31 Mar 2008 22:03:00 +0530
Newsgroups: comp.lang.c

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.


<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy