これらの複数のエラーと警告があり、ほぼすべてを試しましたが、わかりません。あなたの助けは大歓迎です!これは私のコードです:
#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>
あなたの助けは大歓迎です!!