Electrical and Computer Engineering
2 of 29
UAH
CPE 112
Using Files
•All of the cin and cout operations work for files.
•Declaring File Streams
–ifstream inFile;
–ofstream outFile;
–       (With these data types, you cannot read from and write to the same file)
•Opening Files
–inFile.open(“cone.dat”);
–outFile.open(“results.dat”);
–  (Open associates a stream variable used in your program with a physical file on disk.)
•Specifying File Streams in Input/Output Statements
–inData >> htInInches >> diamInInches >> redPrice
–       >> bluePrice >> greenPrice;
–outData << “The painting cost for” << endl;
•