how to handle wrong inputs?

Hi all,

I am programming a Formula 1 Planer right now with lots of menus (Console program). To get to a certain menu the user has to press a number (int). How can i make the program recognize that the user entered a character instead and make it react on that input error?
Im pretty new to all this.

Maybe someone can help me.

Thanx and Greetz


  • Read it as a string instead, and verify it yourself.

  • : Read it as a string instead, and verify it yourself.
    you can try and initialize the input to char.
    try something like the following:

    char input;

    while(input != '6') //whatever number is the exit number

    if (input == '1') //or however you have the menu set up


    by putting the numbers in single quotes the char will take any alpha key strokes and read them as not the right choices and reprint the menu or choice..or what ever it is you are useing.
    hope it helped a little but since i could not see any code to go by, i hope you can get something out of this.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!