About

Kannur University btech CSE study materials, question papers, syllabus . . .

Thursday, July 4, 2013

S4 - HARDWARE LAB - TASM - COPYING A FILE

/*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