C++ Program to Read From a Text File and Than Write in Another Text File Full Project For Beginners

  • Post author:
  • Post category:c++
  • Post comments:0 Comments

 

 

main.cpp

 

 

#include<fstream.h>
void main()
{

ofstream fout(“sare1.txt”); //create a file to write
ifstream fin(“sare1.txt”);
fout<<“Hello….!!”;
fout.close();                            //closing the file
fout.open(“sare2.txt”); //create file to write
char ch;
while(fin) //loop wiill run till end of file
{
fin>>ch;       //reading data from file
fout<<ch;       //writing data to file
}
fin.close();
fout.close();
}

Leave a Reply