At line 17
the user will press the enter key after typing the value of
option
. That keystroke remains stored in the input buffer as a newline character '\n'.
Later, when the execution reaches line 30,
|
getline (cin, msgToEncrypt);
|
the program will read from the input buffer until it reaches the newline '\n'. Thus it reads an empty string and the user doesn't get any chance to type anything.
The solution is after the
cin >> option
, remove the unwanted trailing newline.
A usual solution is to add an ignore() statement, for example
after line 17. Another possibility is to change line 17 to
Note the ws, that tells the program to read and skip any whitespace after the option. Whitespace includes ordinary spaces, tab characters and newlines.