c語言-複製檔案(同步讀寫另一種版本)
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fptr1,*fptr2;
char ch;
int count=0;
fptr1=fopen("runoob.txt","r");
fptr2=fopen("runoob2.txt","w");
if( fptr1!=NULL && fptr2!=NULL)
{
while( (ch=getc(fptr1))!=EOF)
{
printf("%c",ch);
putc(ch,fptr2);
}
printf("\n");
fclose(fptr1);
fclose(fptr2);
printf("copy YES!!\n");
}
else
printf("copy NO!!\n");
system("PAUSE");
return 0;
}
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fptr1,*fptr2;
char ch;
int count=0;
fptr1=fopen("runoob.txt","r");
fptr2=fopen("runoob2.txt","w");
if( fptr1!=NULL && fptr2!=NULL)
{
while( (ch=getc(fptr1))!=EOF)
{
printf("%c",ch);
putc(ch,fptr2);
}
printf("\n");
fclose(fptr1);
fclose(fptr2);
printf("copy YES!!\n");
}
else
printf("copy NO!!\n");
system("PAUSE");
return 0;
}
留言
張貼留言