中的結構中我試圖在加載參數的函數中打開文件,然後將其保存到包含args的結構中,以便以後在其他函數中使用。但是我似乎無法正確保存它(FILE * A,* B等於0x0)。這是我到目前爲止:將FILE *保存到C
struct Args
{
int action; /* holds action token (see teacts)*/
int error;
FILE *A,*B; /* files containing matrixes*/
int r,s; /* start coordinates*/
int power,dir; /* used in some other function */
} Args;
void getArgs(int argc, char *argv[],struct Args * args)
{
....
testopen(argv[4],args->A);
....
}
int openFile (const char *arg, FILE *input)
{
input = fopen(arg,"r");
if (input == NULL)
return (1);
else
return (0);
}
int main (int argc, char **argv)
{
struct Args args = {.action = A_ERROR};
getArgs(argc,argv,&args);
....
}
有誰能告訴我我做錯了什麼?
可能你已經使用'args'更經常的名字:) – thumbmunkeys
你會得到什麼錯誤?認爲你應該顯示更多的代碼, – Cyclonecode
在這裏發佈一個錯誤,請 – azat