R
Ralmin
sugaray said:hi, it just came up my mind that since we can get the length
of any given string literal S with 'sizeof S-1', so, what's
the merit of library function strlen()'s existence ? thanx
in advance for your instruction.
The other replies to your post have covered the case of applying sizeof to
something other than a string literal.
I just thought I would point out that even string literals can give quite
different results between sizeof(S)-1 and strlen(S).
consider when S is "hello \0 world".
sizeof "hello \0 world" - 1 == 13
strlen("hello \0 world") == 6