小编cre*_*rea的帖子

不兼容的指针类型

我刚刚开始编程,所以指针和数组让我很困惑.该程序只是将0-9的随机数分配到数组中并打印出来

(#include <stdio.h> #include <stdlib.h> #include <time.h>)

int function(int *num[]){                         
     int i;
     for(i=0; i<10; i++){
          srand((unsigned)time(NULL));
          *num[i] = rand()%10;                     
          printf("%d", *num[i]);
     }
     return 0;
}

int main(){
     int num[10];
     function(&num);              // incompatable pointer type (how do i fix this?)
     return 0;
}
Run Code Online (Sandbox Code Playgroud)

谢谢

c arrays types pointers function

4
推荐指数
1
解决办法
546
查看次数

标签 统计

arrays ×1

c ×1

function ×1

pointers ×1

types ×1