Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我在C中数组的函数调用中出错了?_C_Arrays - Fatal编程技术网

我在C中数组的函数调用中出错了?

我在C中数组的函数调用中出错了?,c,arrays,C,Arrays,我使用数组在C中进行函数调用时遇到了一个意外错误,我对C有一点了解,不知道如何修复它。主要功能的代码附在下面 void sum_matrices (int m1[][NUM_COLS], int m2[][NUM_COLS], int num_rows, int result[][NUM_COLS]); void print_matrix (int m[][NUM_COLS], int num_rows); void print_array (int a[], int len); int ma

我使用数组在C中进行函数调用时遇到了一个意外错误,我对C有一点了解,不知道如何修复它。主要功能的代码附在下面

void sum_matrices (int m1[][NUM_COLS], int m2[][NUM_COLS], int num_rows, int result[][NUM_COLS]);
void print_matrix (int m[][NUM_COLS], int num_rows);
void print_array (int a[], int len);

int main(void) {

    int my_matrix_1[][NUM_COLS] = {{1, 5, 3, 4, 2},
                                   {7, 1, 4, 1, 7},
                                   {6, 9, 2, 0, 5}};
    int my_matrix_2[][NUM_COLS] = {{7, 8, 3, 3, 4},
                                   {1, 3, 7, 8, 2},
                                   {1, 3, 5, 6, 0}};
    int num_rows = 3;
    int result[num_rows][NUM_COLS]; // finish this line of code to create the result matrix to pass to sum_matrices

    // add call to sum_matrices to add my_matrix_1 and my_matrix_2

    sum_matrices (my_matrix_1[][NUM_COLS], my_matrix_2[][NUM_COLS], num_rows, result[][NUM_COLS]);

    print_matrix(my_matrix_1, num_rows);
    printf("\n");
    print_matrix(my_matrix_2, num_rows);
    printf("\n");
    print_matrix(result, num_rows);
    return 0;
}
在函数
main
中对函数
sum\u矩阵的“调用”

sum_matrices (my_matrix_1[][NUM_COLS], my_matrix_2[][NUM_COLS], num_rows, result[][NUM_COLS]);
是函数的前向声明和函数调用的混合体,但两者都不完整,也不允许以该形式出现在该位置

要调用函数,请编写

sum_matrices (my_matrix_1, my_matrix_2, num_rows, result);
在函数
main
中对函数
sum\u矩阵的“调用”

sum_matrices (my_matrix_1[][NUM_COLS], my_matrix_2[][NUM_COLS], num_rows, result[][NUM_COLS]);
是函数的前向声明和函数调用的混合体,但两者都不完整,也不允许以该形式出现在该位置

要调用函数,请编写

sum_matrices (my_matrix_1, my_matrix_2, num_rows, result);

你可以告诉我们错误是什么吗?看看这些代码,你可能会得到比你所说的一个错误更多的错误。这是你的全部密码吗?您在理解/修复时遇到的错误是什么?您是否可以告诉我们错误是什么?查看这些代码,您可能会收到比您所说的一个错误更多的错误。这是你的全部密码吗?您无法理解/修复的错误是什么?