I'm not quite sure what is happening here, just that after much cutting of code I am still able to recreate the error and have narrowed it down to this section.
If I remove the part where it asks for encryption/decryption it allows user input. However, if it that portion is included, it skips over the cin.getline(input, MAXLN); call and displays all the cout's as if input was blank. Any ideas? I'm compiling under linux but you can feel free to compile it under windows. It really doesn't matter to me.
And the code:
Code:
#include <iostream>
using namespace std;
const int MAXLN = 128;
bool encrypted;
int main(int argc, char * argv[])
{
char input[MAXLN]; //Holdind the string
char temp;
cout << "Press 1 to encrypt. Press 2 to decrypt.\n";
cin >> temp;
if(temp == '2') //Decryption needed
{
encrypted = true;
cout << "Decryption it is then!" << endl;
}
else
{
if(temp == '1')
{
encrypted = false;
cout << "Encryption is it then!" << endl;
}
else
{
cout << "You should have entered a number!" << endl;
return 1;
}
}
cout << "\nPlease enter in the text you would like to modify:" << endl;
//grab the input string
cin.getline(input, MAXLN);
cout << "You entered: " << input << endl;
return 0;
}