C++ getline method not working

前端 未结 4 1998
借酒劲吻你
借酒劲吻你 2021-01-24 23:41

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

4条回答
  •  失恋的感觉
    2021-01-24 23:51

    Use :

    cin.ignore ( std::numeric_limits::max(), '\n' );

    to eat newlines from previous input std::cin >> op;

    header -

    Other way would be :

        while (std::getline(std::cin, str)) //don't use string
        if (str != "")
        {
           //Something good received
    
            break;
        }
    

提交回复
热议问题