ACP4_3

//BCA Support //www.bcasupport.xyz #include <stdio.h> void main() { FILE *fp1,*fp2,*fp3; char f1name[13],f2name[13],f3name[13]; char ch; int a=1; clrscr(); printf("\nEnter file 1 name : "); flushall(); gets(f1name); printf("Enter file 2 name : "); flushall(); gets(f2name); fp1=fopen(f1name,"r"); fp2=fopen(f2name,"r"); if(fp1==NULL || fp2==NULL) { printf("\nFile(s) not found."); getch(); exit(); } printf("Enter new file name : "); flushall(); gets(f3name); fp3=fopen(f3name,"w"); if(fp3==NULL) { printf("\nError in creating file."); getch(); exit(); } fprintf(fp3,"%d. ",a++); while(!feof(fp1)) { ch=fgetc(fp1); fputc(ch,fp3); if(ch=='\n') fprintf(fp3,"%d. ",a++); } fprintf(fp3,"\n%d. ",a++); while(!feof(fp2)) { ch=fgetc(fp2); fputc(ch,fp3); if(ch=='\n') fprintf(fp3,"%d. ",a++); } printf("\nText in new file :\n"); fcloseall(); fp3=fopen(f3name,"r"); while(!feof(fp3)) { ch=fgetc(fp3); printf("%c",ch); } fcloseall(); getch(); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.