C++ Library Reference

Opening and Closing Files

You can close the fstream and then open it with another file. For example, to process a list of files provided on the command line:


ifstream infile; 
for (char** f = &argv[1]; *f; ++f) { 
   infile.open(*f, ios::in); 
   ...; 
   infile.close(); 
}