The
while
loop has no exit condition.
"How can I make it work properly?" — well, it depends what do you mean "properly". If you want, add a condition for exit right after line with
while
, such as
while (cin>>ch ) {
if (ch == 'q') break;
switch (ch) {
}
}
in this case the loop will exit on 'q' ("quit").
—SA