- #1
John O' Meara
- 330
- 0
How do you make a number of input file streams, one for each input file so that can copy/append the contents of these files to one output file? The number of input files is only known at run time and varies from run to run of the program. The input file names are first stored in a linked list. Would you use RTTI?
where: getCount(), getValue() and getNextEntry() are member functions of charList, a linked list of input file names. Any suggestions would be appreciated.
Code:
int main()
...
charList *ptrFile;
charList filesin;
ptrFile = &filesin; // is the linked list object
ifstream ifs;
ofstream ofs;
...
for (int i = 0; i < ptrFile->getCount(); i++) {
ifs.open(ptr->getValue(), ios::in);
...
copyFile(ifs, ofs); // copy contents of an input file to the output file
ifs.close():
ptrFile = ptrFile->getNextEntry();
}
ofs.close();
return 0;
}