Hi,
I've started trying to learn C++, in the hopes of maybe doing something with Orbiter in the future.
With the basic stuff I have learned, I decided to try writing a decimal-binary converter, but I'm already stuck at the beginning.
The following code gets stuck in an infinite loop if i select anything else than 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9. Can anyone tell me why?
I've started trying to learn C++, in the hopes of maybe doing something with Orbiter in the future.
With the basic stuff I have learned, I decided to try writing a decimal-binary converter, but I'm already stuck at the beginning.
The following code gets stuck in an infinite loop if i select anything else than 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9. Can anyone tell me why?
Code:
#include <iostream>
using namespace std;
int main()
{
for( int b = 0; b == 0;)
{
int iSelection = 0;
cout << "*************************************" << endl
<< "* ---Menu--- *" << endl
<< "*************************************" << endl
<< "1 - Convert from decimal to binary " << endl
<< "2 - Convert from binary to decimal " << endl
<< "3 - Exit program " << endl << endl
<< "Please choose: ";
cin >> iSelection;
if( iSelection == 1 )
cout << "Chose 1n";
else if( iSelection == 2 )
cout << "Chose 2n";
else if( iSelection == 3 )
b = 1;
else if( iSelection == 0 )
cout << "nWrong selection" << endl;
else
cout << "nWrong selection" << endl;
}
return 0;
}