Without having looked over the code too much, here's my take on what (might be) happening:
After you run
cin >> option;
on line 37 (say you picked 1), there's still a newline character left in the input buffer (since
cin only took out the 1 and left the newline character from you pressing the Enter key in).
Then
getline(cin, message);
runs on line 47, but it immediately encounters a newline character (that you still haven't gotten rid of), so it treats that as its signal to stop taking input, so
message ends up blank.
In fact, if you want to test it out, when the program asks you to pick an option, type
1 This is my message, wheeeee! |
and you'll find that it'll encrypt the message "This is my message, wheeeee!".
The "proper" way to get rid of that newline character (and whatever else you might have typed in between) is to put this right after
cin >> option;
:
cin.ignore(numeric_limits<streamsize>::max(), '\n');
(You'll need to
#include <limits>
as well).