Merging 2 Files

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2009
Posts: 39
Reputation: niXman is an unknown quantity at this point 
Solved Threads: 10
niXman's Avatar
niXman niXman is offline Offline
Light Poster
 
0
  #11
26 Days Ago
  1. int main() {
  2. std::string fn1("");
  3. std::string fn2("");
  4. std::string out("");
  5.  
  6. merge(fn1, fn2, out);
  7.  
  8. return 0;
  9. }
Я из Молдавии. Говорю на Русском.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 39
Reputation: niXman is an unknown quantity at this point 
Solved Threads: 10
niXman's Avatar
niXman niXman is offline Offline
Light Poster
 
0
  #12
26 Days Ago
This solution has one condition. Both the original file must be the same size, otherwise copying will occur until the reach the end of the smallest file.

PS
Since the function requires arguments of type "const std::string &", then it can pass arguments to the type "const char *". In this case, in the stack will be created temporary object of type "const std::string", which destructed when you exit the function body.

ex.:
  1. merge("file1.txt", "file2.txt", "outfile.txt");
Last edited by niXman; 26 Days Ago at 3:52 am.
Я из Молдавии. Говорю на Русском.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,813
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster
 
0
  #13
24 Days Ago
If you can get it to work without a function, it's a matter of converting that code so that it's inside of a function. Post the code that works where it's all in main.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 10
Reputation: Kaotic07 is an unknown quantity at this point 
Solved Threads: 0
Kaotic07 Kaotic07 is offline Offline
Newbie Poster
 
0
  #14
24 Days Ago
Yeah i got it working, thanks for all the help
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC