suppose i have in my code written following :-
char *abc = " Who cares";
int len= strlen(abc);
This provides me the length of abc . My Doubt is how does Strlen determines the length of
abc here . Certainly it looks for null termination and returns the value . But that does that mean that abc is assigned Null at the place where i am initializing it with value ” Who cares ” ?
Yes,
strlenwalks through the memory pointed to byabcuntil it finds a null termination character.abcis not initialized with null. The compiler places the string somewhere in memory (including an implicit null termination character);abcis then initialized with the address of the first character in the string.So: