在c语言中将动态数组传递给函数

在c语言中将动态数组传递给函数,c,function,C,Function,创建此动态阵列后: int *A = (int *) calloc(n,sizeof(int)); int *B = (int *) calloc(n,sizeof(int)); int *C = (int *) calloc(n,sizeof(int)); 我需要将它们传递给这个函数function2(A,B,C,n)但是我得到了函数“function2”的隐式声明。请帮助。提前谢谢。在调用函数之前,您需要声明或定义函数。比如: void function2(int *a, int *b,

创建此动态阵列后:

int *A = (int *) calloc(n,sizeof(int));
int *B = (int *) calloc(n,sizeof(int));
int *C = (int *) calloc(n,sizeof(int));

我需要将它们传递给这个函数
function2(A,B,C,n)但是我得到了函数“function2”的隐式声明。请帮助。提前谢谢。

在调用函数之前,您需要声明或定义函数。比如:

void function2(int *a, int *b, int *c, int n)
{
    ...
}

int main(int, char **)
{
    int *A, *B, *C, n = 123;

    ...

    A = (int *) calloc(n,sizeof(int));
    B = (int *) calloc(n,sizeof(int));
    C = (int *) calloc(n,sizeof(int));

    function2(A, B, C, n);

    ...

    return 0;
}


如何声明function2()?我重新标记了它,因为它似乎与动态数组无关。
void function2(int *a, int *b, int *c, int n);

int main(int, char **)
{
    int *A, *B, *C, n = 123;

    ...

    A = (int *) calloc(n,sizeof(int));
    B = (int *) calloc(n,sizeof(int));
    C = (int *) calloc(n,sizeof(int));

    function2(A, B, C, n);

    ...

    return 0;
}

void function2(int *a, int *b, int *c, int n)
{
    ...
}