Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.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 - Fatal编程技术网

C 未调用的函数

C 未调用的函数,c,C,我编写了一个程序,其中调用了一个函数,该函数返回一个二维数组指针,并将二维数组作为参数。但不知何故,在运行函数时没有调用该函数。我想不出来。有什么建议吗 #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; FI

我编写了一个程序,其中调用了一个函数,该函数返回一个二维数组指针,并将二维数组作为参数。但不知何故,在运行函数时没有调用该函数。我想不出来。有什么建议吗

#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;
}
#包括
#包括
符号字符**补码(变量[20][20]的符号字符编号);
内部主(空)
{
文件*ptr_文件;
文件*ptr_文件1;
文件*ptr_文件2;
有符号字符**无变量或3;
//有符号字符**无变量或2;
签名字符i,j,k,w;
变量[20][20]的符号字符编号,变量2[23][1000]的符号字符编号;
//标准作业程序[1]的字符编号;
//字符a=无SOP[0];
//字符值[a][10];
ptr_file=fopen(“part1.txt”、“r+”);
如果(!ptr_文件)
返回1;
对于(i=0;i<2;i++)
{
fgets(没有变量[i],20,ptr_文件);
}
对于(i=0;i<0个变量[1][0];i++)
{
fgets(没有变量[i+2],20,ptr_文件);
}
fclose(ptr_文件);
有符号字符var=2+(没有变量[1][0]-48);
对于(i=0;i<(var);i++)
{
对于(j=0;j<20;j++)
{
变量[i][j]的数量=变量[i][j]的数量-48;
}
}
对于(i=0;i<23;i++)
{
//对于(j=0;j更改此行:

no_of_variables_or3 = complement(no_of_variables[20][20]);
将是:

no_of_variables_or3 = complement(no_of_variables);

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

最好的建议是-让我们看看您的代码。.如果您无法通过查看代码找到错误,那么您怎么能期望我们在没有看到的情况下找到错误呢?o.OEither发布一些代码或自己找出它。补码的定义在哪里?为什么您可以用标量填充它?为什么要将它赋给从未在任何地方声明过的东西?函数在哪里?@steve我没有声明变量或3的值。将返回的值赋回来是否有错误?显示的内容看起来不错。是否有意义取决于
complete()
内部发生的情况。