I assign the same string value to a pointer and a char
array
char *str = "hello" "world";
char str1[] = "hello" "world";
Then use sizeof()
function to return their lengths
sizeof(str); // on my computer, it's 8 !!
sizeof(str1); // return 11, which is right
But both of them can be printed out right by %s
:
printf("%s\n%s\n", str, str1);
So why does sizeof(str);
return a wrong value ?