main()
{
FILE *fp1,*fp2;
char c;
fp1=fopen("sample.txt","a");
fp2=fopen("hello.txt","r");
if(fp1==NULL)
{
printf("\n file does not exist");
exit(1);
}
if(fp2==NULL)
{
printf("\n file does not exist");
}
while((c=getc(fp1))!=EOF)
{
putc(c,fp2);
}
printf("\n second file is concatenated to first file");
}
OUTPUT:
second file is concatenated to first file
NOTE: sample.txt and hello.txt files are already existing files. after executing the program hello.txt file contents are concatenated to hello.txt
C program to merge two files into third file
C program to create a file and display file contents on to the screen , file handling in c, random access to a file, random handling in file, random file handling in c, random access to a file in C, getc(), putc(), fopen(), fclose(),getw(),putw(), c program to display file contents on to the screen. different typed of modes in files. differentiate between r and r+ mode, w and w+ mode , a and a+ mode.EOF, end of the file.
No comments:
Post a Comment