/* write a c program to append the content of one file into another */
#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
FILE *ft,*fs;
char str3[80],str4[80];
char ch;
clrscr();
fs=fopen("a.txt","r");
if(fs==NULL)
{
printf("source file cannot open");
exit(0);
}
ft=fopen("b.txt","a");
if(ft==NULL)
{
printf("source file cannot open");
exit(0);
}
while(1)
{
ch=fgetc(fs);
if(ch==EOF)
break;
else
fputc(ch,ft);
}
fcloseall();
getch();
}
/*
Type EXIT to return to Turbo C++. . .Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\TC\BIN>type a.txt
this is muy collage
C:\TC\BIN>type b.txt
this is muy collage
this is muy collage
C:\TC\BIN>
C:\TC\BIN>exit
*/
No comments:
Post a Comment