0
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?

2
Contributors
1
Reply
12
Views
2 Years
Discussion Span
Last Post by Maritimo
0

What is the proble you have with this code?
1 Do not compile?
2 Do not give the expected results?
3 You do not undertand what is does?
4....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.