Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 25th, 2005, 12:23 PM   #31
jayme
Professional Programmer
 
jayme's Avatar
 
Join Date: Nov 2005
Location: Canada
Posts: 495
Rep Power: 0 jayme is an unknown quantity at this point
Send a message via MSN to jayme
This is one of the areas that im trying to correct the problem in.

do{ // This is the strength loop, if you enter a number larger than 20 or less than 1, you will be taken back to this step.
    Points = 20;
    cout << "Enter your strength: "; 
    cin >> Str;
          if ( Str < 1 ) { // If the input is less than 1, the string below is executed and you will be asked to input a new integer.
               cout << "You Must spend at least one point!\n\n"; 
               }
          if ( Str > Points - 2 ){ // If the input is greater than the existing points, the string below will be executed and you will be asked to input a new integer.
          cout << "You don't have enough points!\n\n";
          }

} while ( Str > Points - 2 || Str <= 0 );
        cout << "Strength leveled up to " << Str << "!" << endl; // Lets you know that your selected integer was successfully added.
         Points = Points - Str; // Adds the selected points on to strength and reduces that same amount from your remaining skill points.
         cout << "You have " << Points << " skill points remaining.\n\n";
__________________

Quote:
Originally Posted by Mohamed Jihad
Durka durka!
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it.

Download Code::Blocks now!
jayme is offline   Reply With Quote
Old Nov 25th, 2005, 12:51 PM   #32
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
cout << "Enter your strength: "; 
cin >> Str;
Here you must also clear the input and sync the stream.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Nov 25th, 2005, 3:27 PM   #33
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
Quote:
Originally Posted by Cache
One problem I have noticed though, atoi() seems to convert all non integer values (a, b, c, ect) to 0.
Is the above quote voodoo and bullshit?
Just mild bullshit. Atoi doesn't convert non-integers. It does indicate an error if you request it to, which seems appropriate, and not a "problem".
Quote:
Originally Posted by C++ reference
int atoi ( const char * string );

Convert string to integer.
Parses string interpreting its content as a number and returns an int value.

Parameters.

string
String representing an integer number. The number is considered until a non-numeric character is found (digits, and signs are considered valid numeric characters for this parameter as specified in format). The format used is:
[whitespaces][+|-][nnnnn]
(where whitespaces are any tab or space character and nnnnn may be any number of digits)

Return Value.
The converted integer value of the input string.
On overflow the result is undefined.
If an error occurs 0 is returned.
@ the OP. You aren't implementing the solutions given. Oddly enough, they aren't solutions unless you actually use them. What's the point in giving them to you?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 25th, 2005, 4:06 PM   #34
jayme
Professional Programmer
 
jayme's Avatar
 
Join Date: Nov 2005
Location: Canada
Posts: 495
Rep Power: 0 jayme is an unknown quantity at this point
Send a message via MSN to jayme
Ah hah! I finally figured out how i was gona go about fixing this little problem, thanks to dawei's help. Thanks
__________________

Quote:
Originally Posted by Mohamed Jihad
Durka durka!
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it.

Download Code::Blocks now!
jayme is offline   Reply With Quote
Old Nov 25th, 2005, 5:32 PM   #35
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Quote:
Originally Posted by jayme
Ah hah! I finally figured out how i was gona go about fixing this little problem, thanks to dawei's help. Thanks
LOL???
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Nov 25th, 2005, 6:54 PM   #36
jayme
Professional Programmer
 
jayme's Avatar
 
Join Date: Nov 2005
Location: Canada
Posts: 495
Rep Power: 0 jayme is an unknown quantity at this point
Send a message via MSN to jayme
forget it.. Worked for the strength and intel, but agility would just add 8 skill points whenever a letter or invalid character was entered.
__________________

Quote:
Originally Posted by Mohamed Jihad
Durka durka!
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it.

Download Code::Blocks now!
jayme is offline   Reply With Quote
Old Nov 25th, 2005, 7:05 PM   #37
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
The problem, Jayme, and this isn't criticism, just fact, is that you have some concept in your mind of what you're trying to do. Further, you're sitting in front of your system with a visibility of everything you've done. All we get is snippets and whatever you think to post about them. It's a handicap. The only way you can get "full service" is to present as much as you possibly can, as clearly as you possibly can.

If you think you need to show a pot-load of code, feel free to zip it up and attach it to a post. There is no magic here. There is only thought and sweat and experience (of whatever level). I realize that there was a lot of digression and misdirection. Sometimes that happens. You can either say, "Oh eff it," and write it off, or you can continue to ask for help, providing what information you can, to the best of your ability.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 25th, 2005, 7:09 PM   #38
jayme
Professional Programmer
 
jayme's Avatar
 
Join Date: Nov 2005
Location: Canada
Posts: 495
Rep Power: 0 jayme is an unknown quantity at this point
Send a message via MSN to jayme
well, i've been looking at the different possible ways shown here how i could have gone about avoiding the problem im having, only to come to my senses.. My code is ugly. I have decided to re-write the whole thing, since im not too far along so it should only take about 10 mins lol. Knowing what i know now, I will most likely be able to "overcome" this obsticle.
__________________

Quote:
Originally Posted by Mohamed Jihad
Durka durka!
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it.

Download Code::Blocks now!
jayme is offline   Reply With Quote
Old Nov 25th, 2005, 7:27 PM   #39
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You'll be having the same problems years from now, just a different level. You'll always look back on your old code with something approaching disgust. Name of the game. Post for help when you're ready, or need it.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:38 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC