|
|
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.
|
|