I think the getline on line 17 and 67 is incorrect because the program shows both the "Enter a message" and "Enter key" on the same line (when ran) and does not allow for a message to be entered, only the key. I need it to be able to do both as this is an encryption/decryption program. Any help would be appreciated.
Check line 19. key is defined as an int: is that what you enter?
If you do not enter an int, then the stream std::cin enters a failure state, which causes all further attempts to read from the stream to fail immediately.
Yes the key for my encryption is an integer. This is a caesar cipher and it moves the letters X amount over.
Example(also the way it should be entered when the program is run):
Question: Do you want to encrypt or decrypt?
Answer: Encrypt
Please enter message: Hello!
Enter Key: 1
New Message: Ifmmp!
what the program does:
Do you want to encrypt or decrypt?
Answer: Encrypt
Please enter message: Enter Key: 1
New Message:
The program doesnt even give you the option to put something in for the message. I had it working originally without the if statement but when i added that it started messing up.
Is it because you're reading choice with >> ? That leaves the newline in the input stream so the first getline after that reads an empty string. Try reading choice with getline to ensure the newline is eaten.