这里是代码:

问题描述 投票:0回答:1
#include <stdio.h> #include <stdlib.h> void greatest_two(int num, int *arr[num]); int main() { int *dyn_array , num , i; printf("How many elements? "); scanf("%d", &num); dyn_array = (int*) malloc(sizeof(int) * num); if (dyn_array == NULL) exit (1); for (i = 0 ; i < num; i++) { printf("\nInput number %d: ", i); scanf("%d", &dyn_array[i]); } return 0; } void greatest_two(int num, int *arr[num]) { } greatest_two(&dyn_array);

我正在尝试将数组传递给在数组中找到最大两个值的函数。我也在使用动态内存分配。我仍然是c语言的初学者,我认为这是一个简单的错误:...

c arrays pointers dynamic-memory-allocation
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.