我编写了一个程序,其中调用一个函数,该函数返回一个二维数组指针,并将一个二维数组作为参数。但不知怎的,在运行函数时没有调用。我无法弄明白。任何建议
#include <stdio.h>
#include <stdlib.h>
signed char** complement(signed char no_of_variables[20][20]);
int main(void)
{
FILE *ptr_file;
FILE *ptr_file1;
FILE *ptr_file2;
signed char **no_of_variables_or3;
//signed char **no_of_variables_or2;
signed char i, j, k, w;
signed char no_of_variables[20][20], no_of_variables2[23][1000];
//char no_of_sops[1];
//char a = no_of_sops[0];
//char value[a][10];
ptr_file = fopen("part1.txt", "r+");
if (!ptr_file)
return 1;
for (i = 0; i < 2; i++)
{
fgets(no_of_variables[i], 20, ptr_file);
}
for (i = 0; i < no_of_variables[1][0]; i++)
{
fgets(no_of_variables[i + 2], 20, ptr_file);
}
fclose(ptr_file);
signed char var = 2 + (no_of_variables[1][0] - 48);
for (i = 0; i < (var); i++)
{
for (j = 0; j < 20; j++)
{
no_of_variables[i][j] = no_of_variables[i][j] - 48;
}
}
for (i = 0; i < 23; i++)
{
//for( j=0;j<1000;j++){
// outputarray[i][j] = " ";
printf("val%d\n", no_of_variables[i][0]);
}
no_of_variables_or3 = complement(no_of_variables[20][20]);
FILE *optr_file;
optr_file = fopen("output_part1.txt", "r+");
if (!optr_file)
return 1;
for (i = 0; i < 2; i++)
{
fputs(no_of_variables_or3[i], optr_file);
}
for (i = 0; i < no_of_variables_or3[1][0]; i++)
{
fputs(no_of_variables_or3[i + 2], optr_file);
}
fclose(optr_file);
return EXIT_SUCCESS;
}
答案 0 :(得分:0)
更改此行:
no_of_variables_or3 = complement(no_of_variables[20][20]);
是:
no_of_variables_or3 = complement(no_of_variables);
编译器应该通过发出警告来指出这一点。