I\'m sorry but I\'m quite new to C++ but not programming in general. So I tried to make a simple encryption/decryption. However when I added the modification to my previous code
That's because std::cin >> op;
leaves a hanging \n
in your code, and that's the first thing getline
reads. Since getline
stops reading as soon as it finds a newline character, the function returns immediately and doesn't read anything more. You need to ignore this character, for example, by using cin.ignore(std::numeric_limits
(std::numeric_limits is defined in header
), as stated on cppreference.