1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include <iostream>
#include <fstream>
using namespace std;
void GetData(int &, int &, char &, char &, double &);
void outputData(int, int, char, char, double);
int main()
{
int numAdults, numChildren;
char mealType, dayType; //mealType - standard or deluxe;
double mealDeposit; //dayType - is it a weekend, or not.
ifstream fileIn;
fileIn.open("file.txt");
if (!fileIn) {
cout << "Cannot open file, terminating program" << endl;
}
while (fileIn) {
GetData(numAdults, numChildren, mealType, dayType, mealDeposit);
}
outputData(numAdults, numChildren, mealType, dayType, mealDeposit);
fileIn.close();
return 0;
}
void GetData(int &numAdults, int &numChildren, char &mealType, char &dayType, double &mealDeposit)
{
fileIn >> numAdults >> numChildren >> mealType >> dayType >> mealDeposit >> endl;
}
void outputData(int numAdults, int numChildren, char mealType, char dayType, double mealDeposit)
{
cout << numAdults << numChildren << mealType << dayType << mealDeposit << endl;
}
|