From 00f27d2adc4d2c75687d6954fb7421e4041644aa Mon Sep 17 00:00:00 2001 From: Ehmad Saeed <56268280+ehmadsaeed@users.noreply.github.com> Date: Fri, 11 Oct 2019 00:58:04 +0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=AFHandled=20Input=20failure=20case=20?= =?UTF-8?q?in=20menu=20phase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LMS-D.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/LMS-D.cpp b/LMS-D.cpp index 8e8c8da..3623f46 100644 --- a/LMS-D.cpp +++ b/LMS-D.cpp @@ -103,13 +103,13 @@ int main() cout << "2 for Student\n"; cout << "Enter option: "; cin>>option; - if(cin.peek()!='\n') - { - cin.clear(); - cin.ignore(200,'\n'); - cout<<"You gave wrong input.\n"; - option=-1; - } + while (cin.fail()) + { + cin.clear(); + cin.ignore(10000, '\n'); + cout << " Invalid Option\n Choose again"; + cin >> option; + } if(option==1) { if(loadUsers( usersList , passwordsList))