C++: Infinite loop with a simple menu selection

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 into an infinite loop in my code, for example after I select 1 or 2 for encrypting/unencrypting it lets me enter the word, and when I next enter the "shift" for the cipher it runs an infinite loop of the menu.

I had tried for so many hours to debug this, I thought it was a problem with cin, for example when you enter an invalid choice it just throws an infinite loop/

What seems to cause the infininte loops?

Answers


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);

Need Your Help

Multidimensional array unique based on value (not array key)

php arrays multidimensional-array

I have a multidimensional array which I need to be sorted with uniqueness as I have duplicated records, so I need array_unique to go through the array and remove duplicates by the value, e.g.

Reversing the order of a string

java string reverse

So I'm still shaky on how basic java works, and here is a method I wrote but don't fully understand how it works anyone care to explain?

Single Sign on in multiple ASP MVC 3 applications

asp.net-mvc-3 authentication single-sign-on

I have a solution that has two applications. Is it possible to make the user sign in only once?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.