0
std::string ed;
std::cout << "Encrypt or Decrypt? (e/d)\n" << std::endl;
std::cin >> ed;
std::cout<<std::endl;

if (ed == "e")
{
    std::string ch;
    std::string crypt;

    std::cout << "Type, and I shall encrypt.\n";

    std::getline(std::cin, ch);
    std::cout << "\n enter your keyword. \n";
    std::cin >> crypt;

I am trying to write a simple encryption program. It all works like a charm except the input. I heard that inputting a textfile might actually work easier, but I cannot simply give up on this. So when I run this program it just skips the input for "ch", if I declare a char x before, at least gives me an inputline:

char x;
std::cin >> x;
std::getline(std::cin, ch);

This however swallows the first char of input, so the User would have to start every input with an empty character. Is there any way to solve this issue?

best Busssard

jhoepken
  • 1,743
  • 2
  • 16
  • 22
busssard
  • 121
  • 1
  • 1
  • 7

0 Answers0