#include <stdio.h> #include <stdlib.h> int main() { char c = ' '; //1 byte int a = 0; //4 bytes long l = 100; //4 bytes float f = 1.0; //4 bytes int array[10]; int *array_p = array; char *c_p = "abcdef"; char c_array[] = "abcdef"; printf("%d\n", sizeof(array_p)); //pointer size, 4 bytes printf("%d\n", sizeof(array)); //array size, 40 bytes printf("%d\n", sizeof(c_p)); //pointer size, 4 bytes printf("%d\n", sizeof(c_array)); //char array size, including the final char '\0', 7 bytes, different from function strlen, which ignoring the ending char '\0' return 0; } //从这里也可以看出数组和指针并非完全的等价 //注意sizeof不是函数,属于关键字