File IO (contd.)
4. Make sure the “open” worked fine by using fail predicate function:
if (InFile.fail())
{cout<< “Error in file opening\n”;
return 1;}
5. Use the file just like you used cin and cout.
InFile >>..
OutFile << …
6. Close files when done using:
Infile.close();
OutFile.close();
Previous slide
Next slide
Back to first slide
View graphic version