拾遗:不用使 sizeof 获取数组大小
...
#include <stdio.h> #include <unistd.h> int main(void) { int A[256] = {0}; size_t num = (int *)(&A + 1) - (int *)&A; size_t len = (char *)(&A + 1) - (char *)&A; printf("数组元素个数是 %zd\n字节总长度是 %zd\n", num, len); return 0; } [fh@dell Trash]$ ./a.out 数组元素个数是 256 字节总长度是 1024
...
HADEX_ FROM HELL.