C++ stuck in while loop -
this question has answer here:
hello doing simple while loop in c++ , can not figure out why stuck in when proper input give.
string itemtype = ""; while(!(itemtype == "b") || !(itemtype == "m") || !(itemtype == "d") || !(itemtype == "t") || !(itemtype == "c")){ cout<<"enter item type-b,m,d,t,c:"<<endl; cin>>itemtype; cout<<itemtype<<endl; } cout<<itemtype;
if can point out on looking i'd appreciate it. suppossed exit when b,m,d,t or c entered.
your problem in logic. if @ conditions while loop, loop repeat if item type not "b" or not "m" or not "d" etc. means if item type "b", not "m", repeat. want use && instead of ||.
Comments
Post a Comment