Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Vermillion

isdigit()

This topic is 5560 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i seem to be having a problem with the following code... It compiles fine but when i run it it crashes with a fault access violation.. anyway heres the code any help will be greatfully recived. heres the code cout<<"\nEnter the type of snow that has fallen, press:\n[1]Flakey\n[2]Powder\n[3]Wet\ncin>>ResortOne.type; if (!isdigit(ResortOne.type) || ResortOne.type>=4 ||ResortOne.type<=0) { cout<<"Your choice was invalid"<=4 || ResortOne.type<=0); cout<<"\nEnter the depth of snow in mm\ncin>>ResortOne.snow [edited by - vermillion on April 2, 2003 11:51:49 AM]

Share this post


Link to post
Share on other sites
Advertisement
thanks for the help.. but this is actualy a friends code for her assignment so i dont woat to change the way shes coding just solve this problem... thanks for the help anyway... resortone.type is an int the problem is that if you input a char in creates a forever loop... shes looking for a basic way to trap the char input by using isdigit...

Share this post


Link to post
Share on other sites
''1'' != 1
That is in english: the character ''1'' is not the same as the integer value 1.
''1'' == 49

So, you want:

ResortOne.type>=''4'' || ResortOne.type<=''0''

Skizz

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!