Tag Archives: file1

Write a program in C, to copy file1 to another file2 in the same directory 7m Jun2007

Write a program in C, to copy file1 to another file2 in the same directory. 7m Jun2007 Code: #include<stdio.h> void main() { int ch,size=0; FILE *fp1; FILE *fp2; clrscr(); if((fp1=fopen(“readme.txt”,”r”))==NULL) { printf(“FILE DOES NOT EXIST\n”); exit(0); } if((fp2=fopen(“duplicate.txt”,”w”))==NULL) { printf(“FILE CAN NOT BE CREATED\n”); exit(0); } while(!feof(fp1)) { ch=getc(fp1); putc(ch,fp2); size++; } fclose(fp1); fclose(fp2); printf(”… Read More »