Thread: First Game

  1. #16
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Borland Tubro C++ 4.5, maybe I don't have a setting turned on or something.

  2. #17
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    It might be possible you have an old compiler, if so your program
    cannot compile without few changes on other newer compilers.
    But after changing some things it worked fine.

  3. #18
    Me -=SoKrA=-'s Avatar
    Join Date
    Oct 2002
    Location
    Europe
    Posts
    448
    You should check the if the user input is a number. I typed quit (dunno why I just felt like it) and the program went into an infinite loop telling me choose another number.
    SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
    I say what I say, I mean what I mean.
    IDE: emacs + make + gcc and proud of it.

  4. #19
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by -=SoKrA=-
    You should check the if the user input is a number. I typed quit (dunno why I just felt like it) and the program went into an infinite loop telling me choose another number.
    Another good alternative i like to do is writing my own CIN,
    It really isn't that hard. Sokra how about saying how to filter
    out numbers? (i don't use console apps, so i dont know too much
    about them).

  5. #20
    Me -=SoKrA=-'s Avatar
    Join Date
    Oct 2002
    Location
    Europe
    Posts
    448

    All right...

    Originally posted by Travis Dane
    Sokra how about saying how to filter
    out numbers? (i don't use console apps, so i dont know too much
    about them).
    http://cboard.cprogramming.com/showt...threadid=31654
    this is a thread about this but if you want more specific...
    Ok, here's some code to check the input of numbers:
    Code:
    #include <iostream>
    #include <cctype>
    using namespace std;
    
    int main()
    {
    char input;
    cout<<"Please input a number (or q to quit): ";
    cin>>input;
    if(input == 'q')
      return 0;
    else if(isdigit(input))
       cout<<"Thankyou for typing the number "<<input<<endl;
    else
       cout<<"I said a number or q. Go back to school!"<<endl;
    
    return 0;
    }
    You can use this code as a guideline. You can assing input's value to an int var and use it without any problems.
    SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
    I say what I say, I mean what I mean.
    IDE: emacs + make + gcc and proud of it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 10:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM