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
|
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
void getInput(istream &, string &, string &, float &, float &, float &);
int main()
{
string foodName, servSize;
float foodCals, actInten, actMin;
ifstream inputFile;
inputFile.open("/Users/jordanfleming/Documents/programinput.txt");
//while (!inputFile.eof())
//{
getInput(inputFile, foodName, servSize, foodCals, actInten, actMin);
cout << foodName << servSize << foodCals << actInten << actMin << endl;
//}
inputFile.close();
return 0;
}
void getInput(istream &file, string &name, string &size, float &cals, float &inten, float &min)
{
getline(file, name);
getline(file, size);
file >> cals;
file >> inten;
file >> min;
}
|