If I have a file like this and I want to copy this "File1" to "File2", how is this possible to do.
So I will copy File1 so the new file with have the name "File2.txt".
I know that:

std::copy member exists but are not really sure how to use it.

"C:\\File1.txt"

Recommended Answers

All 2 Replies

std::ifstream fin( "file1.txt" ) ;
std::ofstream fout( "file2.txt" ) ;
fout << fin.rdbuf() ;

That worked great. Thanks.

std::ifstream fin( "file1.txt" ) ;
std::ofstream fout( "file2.txt" ) ;
fout << fin.rdbuf() ;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.