|
From: Per W. <pw...@ia...> - 2004-06-21 05:39:03
|
Think about it for a while:
do {
} while (goOn != 'n' || goOn != 'N' || goOn != 'y' || goOn != 'Y');
When would this expression _ever_ be false?
Assume goOn = 'n':
do {
} while ('n' != 'n' || 'n != 'N' || 'n' != 'y' || 'n' != 'Y');
which is:
do {
} while (false || true || true || true);
which is:
do {
} while (true);
You have to replace || with && for a working expression...
/Per W
On Sun, 20 Jun 2004, Noorez Kassam wrote:
> The marked loop keeps going on forever. Even if the condition in false
>
> int main()
> {
> cout << "Welcome to the quiz maker.\n";
> cout << "With this program you can make a Multiple Choice/True or False
> quiz.\n";
> cout << "We need the name of the quiz file: ";
> char* quizName = new char;
> cin.getline(quizName,123);
> strcat(quizName,".qz");
> cout << "If filename exists it will be overwritten\n";
> cout << "Continue [Y\\N]";
> char goOn;
> do//this loop
> {
> cin >> goOn;
> cin.sync();
> if(goOn == 'n' || goOn == 'N')
> return 0;
> }while(goOn != 'n' || goOn != 'N' || goOn != 'y' || goOn != 'Y');//keeps
> running even if goOn == 'y' || goOn == 'Y'
>
> cout << endl << "\nLets start making questions!\n";
> system("pause");
> system("cls");
> Quiz question;
> char contin;
> do
> {
> question = question.createQuestion();
> question.writeQuestion(question,Quiz::type,quizName);
> Quiz::questionNumb = Quiz::questionNumb+1;
> cout << "\nDo you want to add another question [Y\\N] ";
> do
> {
> cin >> contin;
>
> }while(!(contin == 'y' || contin == 'Y' || contin == 'n' || contin
> == 'N'));
>
> }while(contin == 'y' || contin == 'Y');
> }
>
> _________________________________________________________________
> Free yourself from those irritating pop-up ads with MSn Premium. Get 2months
> FREE*
> http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
> Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
> Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
> REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|