Here is my main function i use visual studio 2012 express and the code works fine. My question is how will i terminate this loop when the user Presses the ESC button instead of -1. Although i would prefer a solution that works both in unix and windows, if it is not possible i am most interested in it working for windows.
int _tmain(int argc, _TCHAR* argv[])
{
list mylist;
int value;
cout<<"Give the numbers you want to insert to the list, press -1 to stop\n";
do
{
cin>>value;
mylist.insertf(value);
mylist.sort_list();
mylist.print();
}while(value!=-1);
}
Here are solution for Windows
First solution:
Esc will not be handled when user starts to type till pressing enter. While idle Esc will be handled
Second Solution:
Esc will be handled always in another thread. Immediate exit can be undesirable on some cases
Third Solution and the Best one .Do everything manually
Handling keypress manually. Exit will be called when Esc is Pressed. You can change it to handle more right way