Sum of two arrays

前端 未结 5 1543
攒了一身酷
攒了一身酷 2021-01-23 14:50

The exercise says \"Make a function with parameters two int arrays and k which is their size. The function should return another array (size k) where every element of it is the

5条回答
  •  南方客
    南方客 (楼主)
    2021-01-23 15:09

    Its impossible to first do a[g] when dynamically getting g.

    Your first lines in main should be:

    int i,g;
    int *a,*b;
    printf("Give size of both arrays: ");
    scanf("%d",&g);
    a = (int *)malloc(g*sizeof(int));
    b = (int *)malloc(g*sizeof(int));
    

提交回复
热议问题