void ascending()
{
int i=0;
const int SIZE = 20;
DrinkRecord s[SIZE];
system("cls");
ifstream infile;
infile.open("drinks.txt");//open your file
if(!infile)//check to make sure its open before trying to initialize list items
{
std::cout<<"\nUnable to open file!\n";
}
vector<string> list;//create your empty list
while(!infile.eof())//while the input stream has not reached the end of your file
{
string temp = "";//create a temporary string
for(int i = 0; i < SIZE; i++)
{
infile >> temp;//grab the input
list.push_back(temp);//put it in the next available list slot
++i;
}
}
//sort before entering this loop for output
for(int i = 0; i < SIZE ; i++)
{
cout<<endl<<"Item Number\tItem Name\tQuantity\tUnit Price"<<endl;
do{
infile>>s[i].itemNumber>>s[i].itemName>>s[i].quantity>>s[i].unitPrice;
cout << fixed << showpoint << setprecision (2);
cout<<s[i].itemNumber<<"\t\t"<<s[i].itemName<<"\t\t"<<s[i].quantity<<"\t\t"<<s[i].unitPrice<<"\t\t" << endl;
}while(infile.good());
}
I seriously need help for this. Anyone?