Object Oriented Programming Practical 24
Question 1
Write a C++ program to Read Content From One File and Write it Into Another File.
addcontent.cpp
C
#include<fstream.h>
#include<conio.h>
void main()
{
clrscr();
char c;
ifstream fin;
ofstream fout;
fin.open("abc.txt");
fout.open("xyz.txt",ios::ate);
char ch;
while(!fin.eof())
{
fin.get(ch);
if(fin.eof())
break;
fout << ch;
}
fin.close();
fout.close();
cout<<"\nFile content added to xyz.txt";
getch();
}
Output

Question 2
Write a C++ Program to Copy the Contents of One File Into Another File.
copy.cpp
C
#include<fstream.h>
#include<conio.h>
void main()
{
clrscr();
char c;
ifstream fin;
ofstream fout;
fin.open("abc.txt");
fout.open("xyz.txt");
char ch;
while(!fin.eof())
{
fin.get(ch);
if(fin.eof())
break;
fout << ch;
}
fin.close();
fout.close();
cout<<"\nFile content copied to xyz.txt";
getch();
}
Output
