* Program to open a file to read information from it
* and write that information into another file
* ********************************************************************/
#include "stdio.h"
int main(){
FILE *f1=NULL,*f2=NULL;
char a;
f1=fopen("fileread","r");
if(f1==NULL){
printf("Cannot open File to read");
exit(1);
}
f2=fopen("filewrite","w");
if(f2==NULL){
printf("Cannot open file to write");
exit(1);
}
while(!feof(f1)){
a=getc(f1);
putc(a,f2);
}
fclose(f2);
fclose(f1);
return 0;
}
feof() Checks whether the End-of-File indicator associated with stream is set, returning a value different from zero if it is.
ReplyDeleteit's same as MACRO EOF(==-1) in C.