C++: Infinite loop with a simple menu selection

后端 未结 3 521
-上瘾入骨i
-上瘾入骨i 2021-01-28 22:32

The script I am working on is over a page long, so I am going to link it (one simple file):
http://pastebin.com/7BVHmQGp

I apologize for that. My problem is I get in

相关标签:
3条回答
  • 2021-01-28 22:53

    Try cin.clear, I believe you are constantly reading your initial input character.

        cin >> selection;
        cin.clear(); 
    
    0 讨论(0)
  • 2021-01-28 22:58

    I think you should be ignoring the newline character instead of a space

    I tried with the following and it works on VS2010

        cin.ignore(1, '\n');
        getline(cin, input);
    
    0 讨论(0)
  • 2021-01-28 23:11

    This page should explain all you need to know.

    0 讨论(0)
提交回复
热议问题