ok i have text file it has something like this
item1 5.00 7 no
item2 6.00 9 yes
item3 6.00 8 no
item4 5.00 7 no
and the list goes on
so i have a struct
Code:
#include <iostream>
#include <fstream>
const int CAPACITY=15
struct Database
{
string item;
double cost;
int amount;
string availability;
};
Database list[CAPACITY];
void Get_Info(){
string filename;
cout << "Enter the filename.txt ";
cin >> filename;
ifstream in;
in.open(filename.c_str());
for (int i= 0; i < CAPACITY; index++)
{
string item;
double cost;
int amount;
string availability;
getline(in, list[i].item);
item = list[i].number;
in >> list[i].number;
in.get();
cost = list[i].cost;
in >> list[i].cost;
amount= list[i].amount;
in >> list[i].amount;
availability= list[i].availability;
in >> list[i].availability;
}
}
int main(){
}
my code worked on a previous assignment but can someone explain to me what getline is doing is it getting the 1st item which is a string so i have to call getline and is there a simpler or easier way