欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

size of array 博客分类: c  

程序员文章站 2024-03-17 23:58:16
...
#define num(x) (sizeof (x) / sizeof (*x))

int main(){

   int number[10] = {1,1,1,1,1,1};
   char *teststr[20] = {"","","","","","","","",""};

   printf("Size of number[10] is %d\n", (int)num(number));
   printf("Size of teststr[20] is %d\n", (int)num(teststr));
   return 0;
}