在函数中查找数组长度
ar
temp
ar
sizeof(int)
).
#include <stdio.h>void temp(int ar[]) // this could also be declared as `int *ar`{ printf("%d\n", (int) sizeof(ar)/sizeof(int));}int main(void){ int ar[]={1,2,3}; printf("%d\n", (int) sizeof(ar)/sizeof(int)); temp(ar); return 0;}
MMMHUHU
临摹微笑
茅侃侃
相关分类