gpt4 book ai didi

c - 函数未调用

转载 作者:行者123 更新时间:2023-11-30 21:30:55 25 4
gpt4 key购买 nike

我编写了一个程序,其中调用一个函数,该函数返回一个二维数组指针并接受一个二维数组作为参数。但不知怎的,在运行时该函数没有被调用。我无法弄清楚。任何建议

#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;
}

最佳答案

更改此行:

no_of_variables_or3 = complement(no_of_variables[20][20]);

成为:

no_of_variables_or3 = complement(no_of_variables);

编译器应该通过发出警告来指出这一点。

关于c - 函数未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22511162/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com