I have the same problem as mentioned in the linked question. The console window (in VS 2010) disappears immediately after running the program. I use a cin.get(); at the end of the main function, but the problem still remains. Any idea about the possible reason? You can check out the code in main:
int main()
{
const int arraysize = 10;
int order;
int counter;
int a[arraysize] = {2,6,4,45,32,12,7,33,23,98};
cout<<"Enter 1 to sort in ascending order\n"
<<"Enter 2 to sort in descending order\n";
cin>>order;
cout<<"Data items in original order\n";
for(counter=0;counter<arraysize;counter++){
cout<<setw(4)<<a[counter];
}
switch (order){
case 1: cout<<"\nData items in ascending order\n";
selectionSort(a, arraysize, ascending);
break;
case 2: cout<<"\nData items in descending order\n";
selectionSort(a, arraysize, descending);
break;
default: return 0;
}
for(counter=0;counter<arraysize;counter++){
cout<<setw(4)<<a[counter];
}
cout<<endl;
cin.get();
return 0;
}
link : C++ on Windows - the console window just flashes and disappears. What's going on?