User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,587 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,614 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 365 | Replies: 1
Reply
Join Date: Oct 2007
Posts: 49
Reputation: nicz888 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
nicz888 nicz888 is offline Offline
Light Poster

help needed on a loop again

  #1  
Nov 5th, 2007
never mind i got it. thanks
Last edited by nicz888 : Nov 5th, 2007 at 2:52 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Posts: 124
Reputation: LaMouche is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 15
LaMouche's Avatar
LaMouche LaMouche is offline Offline
Junior Poster

Re: help needed on a loop again

  #2  
Nov 5th, 2007
This is where you input -1 in the second time:

cin >> dayOfWeek;

if (cin.good())
break;

cin.good() evaluates to true and the while loop exits.

Wouldn't it be better to do something like this?

(psuedo code)
tries = 3
while tries > 0
    ask for day
    if day is not >1 and <8
        tries--
    else
        // print/return success
        break
    if tries is 0
        // print/return failure
Last edited by LaMouche : Nov 5th, 2007 at 3:02 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 6:35 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC