API函数应用,fopen,fclose,fseek,fputc,fgetc,fgets,fputs
#include <stdio.h>
int main(int argc, char *argv[])
{
if(argc != 3)
{
printf("please input two file name!\n");
exit(1);
}
int ch;
FILE *fp1;
FILE *fp2;
if((fp1 = fopen(argv[1], "a+")) == NULL)
{
perror("open file error!");
exit(1);
}
if((fp2 = fopen(argv[2], "a+")) == NULL)
{
perror("open file error!");
exit(1);
}
char buffer[1024];
while(fgets(buffer,sizeof(buffer),fp1) != NULL)
{
fputs(buffer,fp2);
}
#if 0
while((ch = fgetc(fp1)) != EOF)
{
fputc(ch,fp2);
}
#endif
return 0;
}