#include <fstream.h>
void main( )
{
char source [ 67 ],
target [ 67 ];
char ch;
cout << endl << "Enter source filename";
cin >> source;
cout << endl << "Enter target filename";
cin >> target;
ifstream infile ( source );
ofstream outfile ( target );
outfile << infile.rdbuf( );
char ch;
cout << endl << "Enter source filename";
cin >> source;
cout << endl << "Enter target filename";
cin >> target;
ifstream infile ( source );
ofstream outfile ( target );
outfile << infile.rdbuf( );
}
Here all the copying is done through the single statement
outfile <<
infile.rdbuf( );
The function rdbuf( ) returns the address of the strstreambuf
where the values are stored.
cplusplus sample programs for coders
ReplyDeletegeneric bubble sort c++ code