我有这些多个错误和警告,我几乎尝试了所有方法,但无法弄清楚。非常感谢您的帮助!这是我的代码:
#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:在函数“main”中:copyfile.c:44:3:警告:从不兼容的指针类型传递“fputc”的参数 2 [默认启用] 在 copyfile.c:1:0 中包含的文件中:/usr /include/stdio.h:573:12:注意:预期为“struct FILE *”,但参数的类型为“char *”</p>
非常感谢您的帮助!!