Wednesday, November 11, 2009

Chap12[C]c Add contents of file on another

Write a program to add the contents of one file at the end of another.

#include "stdio.h"

void main()
{
FILE *fp,*ft;
char ch,ch2;
int f=0;
fp=fopen("c:\\ctxt\\12cc1.txt","a");
ft=fopen("c:\\ctxt\\12cc2.txt","r");

fprintf(fp,"\n");
while(1)
{

ch=fgetc(ft);
if(ch==EOF)
break;

fputc(ch,fp);


}
fclose(fp);
fclose(ft);
}

No comments:

Post a Comment