我寫了一個程序,其中調用了一個函數,它返回一個二維數組指針並將一個二維數組作爲參數。但不知何故運行該功能時不被調用。我無法弄清楚。任何建議函數不叫
#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;
}
最好的建議是 - 讓我們看看你的代碼.. –
如果你無法通過查看你的代碼來發現錯誤,那麼你怎麼能指望我們發現它,而沒有看到它? o.O – haccks
可以發佈一些代碼或者自己想想。 –