char c[] = \"Hello\"; char *p = \"Hello\"; printf(\"%i\", sizeof(c)); \\\\Prints 6 printf(\"%i\", sizeof(p)); \\\\Prints 4
My question is:
Why
pointer and array are different.
char c[] = "Hello"; //declare c as an array. sizeof(c) calculate the size of array 6. char *p = "Hello"; //declare p as a pointer.sizeof(p) calculate the size of pointer,in most machine the size of pointer is 4.
char c[] = "Hello";
char *p = "Hello";
you can also refer to .