from what I understood, both char* and char[] should have the same size, which should be the size of the word+the null terminator
But when I tried getting the size of both a char* and a char[] with the same string inside I got two separate values:
int main(){
char *c = "Hello";
printf("%lu\n",sizeof(c));
char ch[] = "Hello";
printf("%lu\n",sizeof(ch));
return 0;
}
In this case I got that sizeof(c) = 6 and sizeof(ch) = 8
I thought I would be getting the same size which should have been 6, since hello is composed of 5 letter and since it's null terminated in both char* and char[] I should be getting the same value.
Can someone please explaine to me what I failed to grasp ?
Thanks