#include "stdio.h"
#include "stdlib.h"
#define PATH "c:\\demo.txt"
#define NewPATH "c:\\demonew.txt"
#define N 100
void mainx()
{
char Arry[N]={0};
FILE* Pfile=fopen(PATH,"r");
if (Pfile==NULL)
{
printf("文件打开失败!");
}
while (fgets(Arry,N,Pfile)!=NULL);
{
printf("%s\n",Arry);
}
system("pause");
}
void main()
{
char Arry[N]={0};
FILE* Pfile=fopen(PATH,"r");
FILE*Newpfile=fopen(NewPATH,"w+");
if (Pfile==NULL||Newpfile==NULL)
{
printf("文件打开失败!\n");
}
fseek(Pfile,0,SEEK_END);
int size=ftell(Pfile);
printf("size=%d\n",size);
fseek(Pfile,0,SEEK_SET);
for (int i=0;i<size;i++)
{
char ch=fgetc(Pfile);
printf("%c",ch);
fputc(ch,Newpfile);
}
fclose(Pfile);
Pfile=NULL;
system("pause");
}