mardi 22 décembre 2015

unwanted result with loops in c

i want that code will work... now its no matter what i do its loop forever and showing "syntax eror" forever.

this code need to check if answer isnt 'y' or 'n' if it is ask again for answer and then if answer y it will loop again all the func and if answer is n it just do nothing...

char answer = ' ';
int round = 0;
do
{
    round = chooseLevel();
    guess(round);
    while ((answer != 'y') || (answer != 'n'))
    {
        printf("\nWould you like to play again? (y/n): ");
        answer  = getch();
        putch(answer );
        printf ("\nchar is %c\n", answer );
        if ((answer != 'y') || (answer != 'n'))
        {
            printf("Syntax Eror");
        }
    }
}
while (answer  == 'y');

tnx!

Aucun commentaire:

Enregistrer un commentaire