Encrypting/Decrypting using transposition cipher

Hi.
I am writing a program for my CS2400 class as homework where we are to either encrypt a message, decrypt a message, or let the user quit. I began by setting up the functions without writing too much in the definitions. This is my code so far.

#include <iostream>
#include <iomanip>
using namespace std;

void encryption (char message[]);//prototype
void decryption (char message[]);//prototype

int main(){
int ans=0;
char message[100];
while (ans!=3){
cout << "1. Encrypt a message.\n2. Decrypt a message.\n3. Quit\n";
cin >> ans;
if (ans==1){
encryption (message);
}
if (ans==2){
decryption (message);
}
if (ans==3){
break;
}
}

return 0;
}

void encryption (char message[]){
int count=0;
cout << "Please enter a message to be encrypted:\n\n";
cin.get(message[count]);
while (message[count]!='\n'){
count++;
cin.get(message[count]);
}

}

void decryption (char message[]){
int count=0;
cout << "Please enter a message to be decrypted:\n\n";
cin.get(message[count]);
while (message[count]!='\n'){
count++;
cin.get(message[count]);
}

}
(end)
When run, it lets me choose an option of the three, but when choosing encrypt or decrypt, it prints the statement asking for input then makes me choose again without giving me a chance to input anything. Any ideas on why it wont give me a chance to input anything?
I expect you have a line-ending still in the buffer, so it reads that.

Flush the buffer; https://stackoverflow.com/questions/257091/how-do-i-flush-the-cin-buffer
Is there a specific place I should put these?
Topic archived. No new replies allowed.