Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 16th, 2006, 03:12 AM
Authorized User
 
Join Date: Oct 2006
Location: New York, US
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mastrgamr
Default meaning of a warning

is there a place anywere that i can lookup wat each warning for a C++ means?(if that list isnt too big lol)

because i got a warning while compiling this:
----------------------------------------------------------------------
#include <iostream.h>

using namespace std;
int main()
{
    int age;
    cout<<"imma execute a program but first u have to be a certain age!\n";
    cout<<"enter ur age here: ";
    cin>> age;
    cin.ignore();
    if (age == 15) {
        cout<<"GOOD choice!\n";
        }
    else {
        cout<<"OOPS WRONG AGE!!!\n";
        }
cin.get();
return 0;

    int num;
    cout<<"Enterith anyith #(ith lol): ";
    cin>> num;
    cin.ignore();
    cout<<"U enteredith: "<< num<<"\n";
    cin.get();
}
----------------------------------------------------------------------
im not completley done i was just practicin my newbie skill. :D im tryna fix this code so wen i do enter the right age the program wont close how?

__________________
-Stuart Smith
Reply With Quote
  #2 (permalink)  
Old December 16th, 2006, 02:26 PM
Authorized User
 
Join Date: Oct 2006
Location: New York, US
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mastrgamr
Default

i fixed the age problem! but still need hlp with the warnings...

Mŧ~|~®GĂ(v)R~
Reply With Quote
  #3 (permalink)  
Old December 17th, 2006, 05:40 AM
Authorized User
 
Join Date: Oct 2006
Location: , , .
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

helo mastrgamr
  i fixed your problem..
how did you fixed your problem?

you deleted the .h in iostream? coz try your code and it worked fined with me...

.::JHANNY::.

Reply With Quote
  #4 (permalink)  
Old December 17th, 2006, 12:06 PM
Authorized User
 
Join Date: Oct 2006
Location: New York, US
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mastrgamr
Default

with my compiler i can use the .h extension and the regular iostream (without the extension) the problem i had was trying to close the programs when the wrong age is typed. (any age other than 15) but i fixed that.

Mŧ~|~®GĂ(v)R~
Reply With Quote
  #5 (permalink)  
Old December 18th, 2006, 07:27 AM
Friend of Wrox
 
Join Date: Jan 2006
Location: Fort Wayne, Indiana, USA.
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Geo121
Default

Okay I'm a little lost in your question mastrgamr but I think you asked

how to keep the program from closing after you enter the right age?

Once the right age is entered where you typed your if statement

under good choice declare a variable as an int name it condition and give it a value of 1

create a while loop that runs while condition == 1

then inside of the loop give the user something to do

such as an input and if they enter x then it ends the loop

here is an example

int condition = 1;
char exitvar = 'a';
while (condition == 1)
{
     cout << "type x to leave\n";
     cin >> exitvar;
     if (exitvar == 'x')
     {
            condition = 0;
     }
     else
     {
            exitvar = 'a';
     }
}

 ~ Geo

 ~ Don't take life too seriously, you'll never get out alive!
Reply With Quote
  #6 (permalink)  
Old December 18th, 2006, 07:28 AM
Friend of Wrox
 
Join Date: Jan 2006
Location: Fort Wayne, Indiana, USA.
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Geo121
Default

now this is obviously a bare bones example but you get the basic understanding right?

if you have anymore questions just ask

 ~ Geo

 ~ Don't take life too seriously, you'll never get out alive!
Reply With Quote
  #7 (permalink)  
Old December 21st, 2006, 12:16 PM
Authorized User
 
Join Date: Oct 2006
Location: , , .
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

in my case i put the
cin.get();
return 0;
 in order not to close if it is in right choice and put some comments like

 cout<< " press enter blah blah blah.....";

__________________________________________
.::If you quit you loss, If you survive you win::.

.::JHANNY::.

Reply With Quote
  #8 (permalink)  
Old December 22nd, 2006, 07:16 AM
Friend of Wrox
 
Join Date: Jan 2006
Location: Fort Wayne, Indiana, USA.
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Geo121
Default

that is good but you should generally create a loop in case that for some reason they do not want to exit right away or if you come up with something that must be ddone before the exiting later.

 ~ Geo

 ~ Don't take life too seriously, you'll never get out alive!
Reply With Quote
Reply


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
meaning post and get amged Pro PHP 1 August 1st, 2007 06:33 AM
meaning of following Regular expressions buntyindia BOOK: Beginning Regular Expressions 0 June 25th, 2007 04:44 AM
Meaning Of MultiLanguage nir_pankaj C# 8 March 8th, 2007 12:10 PM
Meaning mani_he Beginning PHP 3 January 18th, 2005 11:26 PM
"p2p" what's meaning? shuicanyi Forum and Wrox.com Feedback 4 April 16th, 2004 12:44 PM



All times are GMT -4. The time now is 07:16 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.