STUDENT’S NAME – Sarthak Perti
STUDENT’S UID – 21BCS9572
CLASS AND GROUP – PH21AML-106A
SEMESTER – 2nd
AIM OF EXPERIMENT
WAP to copy contents of one file to another and display it on output screen
Prerequisites
Create two files say codes.txt and cracker.txt inside the same directory where you're
saving our C++ source code. That is, either:
Create two files inside the directory where you're saving your program or going to save
your C++ program of copy file (given below)
Or save your C++ program (that copies the content of one file to another) in that
folder where the two files codes.txt and cracker.txt are created.
Algorithm
STEP 1: ------------------------ START ----------------------------------------
STEP 2: Declare Header file and namespace
STEP 3: In main method declare ch, sourcefile[20],targetfile[20]
STEP 4: Declare File*fs,*ft
STEP5: Input the name of source file and pass through fopen(…)method and store in fs
STEP 6: if fs=NULL print error occurred
STEP 7: Input the name of target file and passthrough fopen(…)method and store in ft STEP 8:ch=fget(fs)
STEP 9: if(ch!=EOF)
STEP10: fput(ch,ft)
STEP 11: ch=fget(fs) goto
STEP 12: print “File copied Successfully” STEP 13: fclose(fs)
STEP 14: fclose(ft)
STEP 15: ------------------------ STOP ---------------------------------
, PROGRAM CODE