The code below is related to calculating length of string
#include <stdio.h>
int strl (char *s);
main ()
{
int len1 = str ("hah");
printf ("%d", len1);
}
int
str (char *s)
{
int length = 0;
while (*s != '\0')
{
length++;
s++;
}
return (length);
}
When I call the function str
, I am assigning a string literal to pointer and not the address of the string literal to the pointer but it turn out that address is stored. How can pointers store address of "hah" without specifying its address?