0
我想通過一個int數組作爲指向函數的指針。目前,我發現了以下錯誤:expected 'int (*)[100]' but argument is of type 'int *' void.
傳遞數組指針作爲參數
void count_frequency(int *number) {
int i;
int len = sizeof number/sizeof(int);
printf("%i\n", len);
printf("reached here");
for(i = 0; i < len; i++){
printf("%i\n", &number[i]);
}
}
int main(){
int i;
int table[MAX];
int len = sizeof table/sizeof(int);
printf("reached before loop\n");
for(i = 0; i < len; i++){
table[i] = random_in_range(0, 20);
}
count_frequency(table);
//printf("%i", sizeof(table)/sizeof(int));
return 0;
}
'INT LEN =的sizeof數/的sizeof(int)的;'手動檢查什麼此返回上不同尺寸的陣列。 – this
什麼返回random_in_range函數? –
閱讀[奇怪的行爲時,打印數組在C中?](http://stackoverflow.com/questions/18009725/weird-behavior-when-printing-array-in-c/18009736#18009736) –