My main menu runs twice after displaying my ascending and descending order function,
i have to scroll up in order to see.
how can i solve that? i don wan the main menu to come up.
here are the codes for function
int main(int argc, char *argv[]); {
std::ifstream input_file("stockdatabase.txt"); std::string value;
std::vector<std::string> file_data;
if (input_file)
{
while (!input_file.eof())
{
std::getline(input_file, value, '\n');
file_data.push_back(value);
}
}
int choice = 0;
do
{
cout<< "Press 1 for descending order"<<endl;
cout<< "Press 2 for ascending order"<<endl;
cout<< "Press 3 to exit"<<endl;
cin >> choice; switch (choice)
{
case 1:
std::cout << "Sorting in Descending Order: \n";
std::sort(file_data.begin(), file_data.end(), DecsendingOrderSorter()); std::for_each(file_data.begin(), file_data.end(), RowPrinter());
break;
case 2:
std::cout << "Sorting in Ascending Order: \n";
std::sort(file_data.begin(), file_data.end(), AscendingOrderSorter()); std::for_each(file_data.begin(), file_data.end(), RowPrinter());
break;
case 3:
system("clear");
exitSubMenu = true;
break;
default:
cout << "You have entered an invalid option, please key in Options 1 ~ 3. Thank you." << endl << endl;
choice = -1;
system("clear");
break;
}
} while (choice != 3);
}
}
ERRORS
----------------------------------------
- Ascending and Descending Order -
----------------------------------------
S/N ItemID Total Qty Item Description
----------------------------------------------------------------------
Press 1 for descending order
Press 2 for ascending order
Press 3 to exit
3
(HERE I ALREADY PRESS 3 TO EXIT)
--------------------------------------------------------------------
- Welcome to Warehouse Management System -
--------------------------------------------------------------------
Login successful! Welcome back Henry Loh!
1) Add new stock
2) Remove stock
3) Edit stock item
4) Search stock item
5) List stock items in ascending or descending order
6) Daily stock summary report
7) Weekly stock summary report
8) Monthly stock summary report
9) Yearly stock summary report
10) Quit Program
Please enter your choice:
THIS IS THE MAIN MENU^
----------------------------------------
- Ascending and Descending Order -
----------------------------------------
S/N ItemID Total Qty Item Description
----------------------------------------------------------------------
Press 1 for descending order
Press 2 for ascending order
Press 3 to exit
OVERWRITTEN BY THIS^