C++ Help

A forum for computer hardware and software issues
Post Reply
regis
Villun
Villun
User avatar
Posts: 3221
Joined: Mon Oct 23, 2006 10:57 am
Location: Dallas, TX
Contact:

Games Played

Ville Awards

MrRegis’s avatar
Loading…

C++ Help

Post by regis » Wed Jun 27, 2007 11:12 am

I can't remember how to do "if" conditional structures.

There's a tiny little part of the program, where it'll ask you a "Yes or No" question. Basically I want it to go like this: if answered yes, it continues to the next section, if answered no then program closes (return 0;).

I'm just asking to see if anyone here knows off hand. If not I'll do more web surfing.

TIA -reeg

Dog
Server Ops
Server Ops
User avatar
Posts: 14317
Joined: Sun Oct 15, 2006 12:12 am
Location: In the bath, having a good think....

Games Played

Ville Awards

Dog - RIP Stevo’s avatar
Loading…

Re: C++ Help

Post by Dog » Wed Jun 27, 2007 11:31 am

You mean something like this:....?

Code: Select all

int main()
 {
 char ans='n';

     while( dir != '\r' )
     {
        cout << "\nIs Regis cool? (y/n): ";
        ans = getche(); 
        switch(ans)
            {
                 case 'y': callroutine(); break; 
                 case 'n': return 0; break;
            }
      } 
 return 0;
 } 
Image

regis
Villun
Villun
User avatar
Posts: 3221
Joined: Mon Oct 23, 2006 10:57 am
Location: Dallas, TX
Contact:

Games Played

Ville Awards

MrRegis’s avatar
Loading…

Post by regis » Wed Jun 27, 2007 11:44 am

Yeah I think so.. will have to try it out. It's been so long since I've work with C++.

Thanks Dog

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests