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;
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?