protect 'gainst bad input

  • Kurgusov

    Kurgusov - 2007-06-24

    Hi Mr McBrine.
    hope your well bro ;)

    I need to get the users input in the question...

    [1]Intro [2]CreateCharacter

    now if I use getch it will not accept an integar.

    if I use scanw it wont accept a char,

    but if I use

    char cont[10];
    flushinp(); //just in case

    it will accept both int and char.
    Is this correct,Ive had problems like this before
    that work only to crash the program later.

    My question being...Is getstr() the only way to protect against erroneous input.

    ;) keep up the amazing work.

    • William McBrine

      William McBrine - 2007-06-25

      I don't really understand the question. But certainly scanw() will accept a char, if you use it correctly.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks