C++ coding question

neilm

Golden Member
Aug 25, 2002
1,108
0
0
Haven't touched C++ in two years so I'm abit rough, anyway need help :)

I'm extracting the contacts of one text file, and putting it in another (which the code attached does)... but I was wondering, how would I go about extracting the contents of two or more different text files and puttin them into the single output file one after the other (in order of whats extracted first).

Thanks for any help.

Note: This ain't homework, or any kind of project... just messing about.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
It depends on how you want to do it.

You could just have another ifstream, or reuse the 'in' ifstream, and redo 'out << in.rdbuf();' after closing in and reopening it with the new file.

Or if you plan on supporting any number of input files you could have a while loop that goes through a list of files and puts them in the destination file on per loop.

Or you could have 2 loops, one loops through the list of files and puts them in an array and then the second loop goes over that array and copies the files to the destination.
 

neilm

Golden Member
Aug 25, 2002
1,108
0
0
That gives me some options to play with... another thing, how would I be able to get the text file date (seen in the properties of the file)?
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Originally posted by: neilm
That gives me some options to play with... another thing, how would I be able to get the text file date (seen in the properties of the file)?

stat
 

neilm

Golden Member
Aug 25, 2002
1,108
0
0
Originally posted by: Armitage
Originally posted by: neilm
That gives me some options to play with... another thing, how would I be able to get the text file date (seen in the properties of the file)?

stat

Sorry can I have an small example of stat for getting the creation date of a file?
 

itachi

Senior member
Aug 17, 2004
390
0
0
if u wanna copy one file to another.. u could always just take the easy way out..
#include <iostream>
#include <fstream>

fstream fs1, fs2;
fs1.open (...); fs2.open (...);
fs1.get (*(fs2.rdbuf ()), EOF);

that'll read directly from fs1 to fs2.

here's how to use fstat in windows..

this crap was acting up.. interpreted a simple preprocessor as a ssi, so i had to change the include statements.