/* “fstream" class is used for both reading and writing a file. So we need to copy the contents of a file into another file than we will
use “fstream”, it has functions capable of both reading & writing in the file. NOTE: both the text file has to be present initially. */
Code:
#include<iostream>
#include<conio.h>
#include<fstream>
using namespace std;
int main ()
{
fstream a,b;
char ch;
a.open("bunty.txt"); //The file from which the content will be copied
b.open("babli.txt"); //The file to which the content will be copied
while (!a.eof())
{
a.get(ch); //reading from file object 'a'
cout<<ch;
b<<ch; //writing to file babli.txt
}
a.close();
b.close();
return 0;
}
Code:
#include<iostream>
#include<conio.h>
#include<fstream>
using namespace std;
int main ()
{
fstream a,b;
char ch;
a.open("bunty.txt"); //The file from which the content will be copied
b.open("babli.txt"); //The file to which the content will be copied
while (!a.eof())
{
a.get(ch); //reading from file object 'a'
cout<<ch;
b<<ch; //writing to file babli.txt
}
a.close();
b.close();
return 0;
}
3 comments:
Hi. This happen if there is a mismatch in encoding schemes that is used to write and read the text file.
2 no m swapping wala Program bnaiye na plz
Sir😭😭😭😭😭 isse Chhota program bnare ki Ni🤜
Post a Comment