copy a file

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

copy a file

 
0
  #1
Mar 9th, 2008
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.


  1. "C:\\File1.txt"
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,089
Reputation: vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all 
Solved Threads: 164
vijayan121 vijayan121 is offline Offline
Veteran Poster

Re: copy a file

 
0
  #2
Mar 9th, 2008
  1. std::ifstream fin( "file1.txt" ) ;
  2. std::ofstream fout( "file2.txt" ) ;
  3. fout << fin.rdbuf() ;
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: copy a file

 
0
  #3
Mar 9th, 2008
That worked great. Thanks.

Originally Posted by vijayan121 View Post
  1. std::ifstream fin( "file1.txt" ) ;
  2. std::ofstream fout( "file2.txt" ) ;
  3. fout << fin.rdbuf() ;
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC