Electrical and Computer Engineering
5 of 29
UAH
CPE 112
An Example Program
 Using Files
• outData << fixed << showpoint;         // Set up floating-pt.
•                                           //   output format
•    // Open the files
• 
•    inData.open("cone.dat");
•    outData.open("results.dat");
• 
•    // Get data
• 
•    inData >> htInInches >> diamInInches >> redPrice
•           >> bluePrice >> greenPrice;
• 
•    // Convert dimensions to feet
• 
•    heightInFt = htInInches / INCHES_PER_FT;
•    diamInFt = diamInInches / INCHES_PER_FT;
•    radius = diamInFt / 2.0;