/*COPYING A
FILE*/
#include<stdio.h>
#include<conio.h>
void main()
{file *f1,*f2;
char ch;
clrscr();
f1=fopen(“c:/09cs00/sithara.txt”,”r”);
f2=fopen(“c:/09cs00/sithu.txt,”w”);
If(f1==NULL)
{printf(“file doed not exit”);
fclose(f1);
fclose(f2);
getch();
exit(0);
}
else
{while (1)
{ch=getc(f1);
If(ch==EOF)
break;
else
putc(ch,f2);
}
}
Printf(“\nfile copied\n”);
fclose(f1);
fclose(f2);
printf(“contents of the file”);
f2=fopen(c:/09cs00/sithu.txt”,”r”);
while(1)
{ch=getc(f2);
If(ch==EOF);
break;
else
printf(“%c”,ch);
}
fclose(f2);
getch();
}
OUTPUT
File copied
Content of the file:welcome






0 comments:
Post a Comment