-4
我有傳遞文件指針的問題。如果函數中有一個帶有文件指針的函數(我的代碼中爲void writequest),該如何傳遞它?在我投入無效的請求之前,它正在工作。程序本身應該從一個充滿電影名稱的文件中讀取,然後將它們放入另一個文件中。當然,請隨時注意我的代碼中的任何其他故障。C傳遞文件指針到一個函數
void writequest(int no)
{
int i, j, loop_ctrl, destination;
int movement;
char lib[loop_ctrl+1][92];
int write_nr[loop_ctrl], sorting[destination];
char searching[92];
char *c;
FILE *watched;
FILE *temp;
FILE *refrom;
FILE *reto;
FILE *towatch;
if(no==1)
{
printf("No match found.\n");
}
else if(no==0)
{
printf("Do you wish you write them into a file?\n1 - Yes\n0 - No\n");
scanf("%d", &j);
if(j==1)
{
tofile(watched, temp, refrom, reto, destination, loop_ctrl, write_nr, lib, movement);
close(towatch, watched, temp, refrom, reto);
remove("To_watch.txt");
rename("temp.txt", "To_watch.txt");
}
else if(j==0)
{
printf("Alright then\n");
close(towatch, watched, temp, refrom, reto);
}
}
}
您是否想將'FILE'指針傳遞給'writerequest'?爲什麼不爲該函數添加一個額外的參數? –
另外,如果你選擇一個像Dumbarse這樣的名字,人們很難認真對待你的問題。 – WildCrustacean
對不起,但這個問題就像「這是一堆代碼,不知道爲什麼它不起作用,幫助我」。如果是@JoachimPileborg說的話,那就更糟糕了,因爲你已經在你發佈的代碼中已經有了例子。編輯:只是想添加一些adivce:如果你想顯示代碼,減少問題的主要問題,減少代碼的方式只顯示(真的只是)你有問題。 – junix