Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-05-2005, 07:07 AM   #1 (permalink)
Sliker_Hawk
Registered User
 
Join Date: Jun 2005
Posts: 1
Sliker_Hawk is on a distinguished road
yes/no cases... (fixed - solution for anyone)

Told to do this by someone...
A'IGHT!

The problem: I had a yes/no case which, when someone entered no, was supposed to restart my loop, and when yes was entered it was supposed to.. skip to teh end of the loop.

It looked like this:
Code:
     while (corrct != 'n' || corrct != 'N')
     {
           system("cls");
           cout<<"Please enter the location for the "<<drvletter<<" drive to redirect to : ";
           cin>>drvdir;
           
           system("cls");
           cout<<"The "<<drvletter<<" drive will redirect to "<<drvdir<<".\n";
           cout<<"Is this correct? (y/n)\n";
           
           cin>>corrct;
           
           switch(corrct)
           {
                         case 'y': case 'Y':
                              break;
                              
                         case 'n': case 'N':
                               cout<<"Please enter the location again.\n";
                               system("pause");
                               system("cls");
                               continue;
                               break;
                              
                         default:
                               cout<<"Invalid choice. Try again.\n";
                               system("pause");
                               system("cls");
                               continue;
                               break;
           }
     }
Now.. Discovering the only problem in that is the while part, I quickly got very excited and attempted to fix it by changing it to:

Code:
while (corrct == 'n' || corrct == 'N')
Which also, did not work... OF COURSE, that is because when the loop started, corrct was not set to 'n', therefore, it skipped the loop.

With a bit of help, I found that this:

Code:
while (corrct != 'y' || corrct != 'Y')
was the way forward.
And amazingly, that does actually work.

Sorry

Last edited by Sliker_Hawk; 06-05-2005 at 07:28 AM.
Sliker_Hawk is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 05:52 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting