我有這些多個錯誤和警告,並且我已經嘗試了幾乎所有的東西,但無法弄清楚。非常感謝您的幫助!這是我的代碼:將一個文件複製到另一個錯誤c
#include <stdio.h>
#include <stdlib.h>
int main()
{
/* Create Usable Variables */
FILE *src_p, *dst_p;
char src_file[20], dst_file[20];
char c;
/* Retrieve Source File Name From User */
printf("Enter Source File Name:\n");
fgets(src_file, 19, stdin);
/* Attempt Opening Source File For Reading */
if((src_p = fopen(src_file, "r")) == NULL)
{
printf("ERROR: Source File Failed To Open...\n");
return(-1);
}
/* Retrieve Destination File Name From User */
printf("Enter Destination File Name:\n");
fgets(dst_file, 19, stdin);
/* Attempt Opening Destination File For Writing */
if((dst_p = fopen(dst_file, "w")) == NULL)
{
fclose(src_p);
printf("ERROR: Destination File Failed To Open...\n");
return(-2);
}
/* Copy Source File Contents Into Destination File */
while((c = fgetc(src_p)) != EOF)
fputc(c, dst_file);
/* Close Files On Success */
fclose(src_p);
fclose(dst_p);
return 0;
}
和錯誤,當我嘗試編譯它是這樣的:
copyfile.c:在函數 '主': copyfile.c:44:3:警告:從不兼容指針類型[默認情況下啓用]傳遞'fputc'的參數2 從copyfile.c包含的文件中:1:0: /usr/include/stdio.h:573:12:note:expected'struct FILE *'但是參數的類型是'char *'
您的幫助非常讚賞ED!
LOL!男人......這樣一個簡單的錯誤,如此頭疼。謝謝。我會在3分鐘內接受你的回答。 –
將來,這些簡單的錯誤可以通過仔細閱讀由編譯器報告的錯誤**輕鬆解決。嘗試從gcc再次讀取錯誤消息,看看你是否理解了@cnicutar給你的信息。你會從中學到很多 – Pankrates
是的,謝謝。是否有更好的C調試器(當然不使用IDE)? –