I have the following variable:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
char op;
And I'm asking the user to enter a character:
printf("\nDeseja realizar novo teste (s/n) ?");
op = getche();
If the user type s
the following code will appear:
printf("\nDigite um número para o dividendo : \n");
scanf("%d", ÷ndo);
printf("\nDigite um número para o divisor : \n");
scanf("%d", &divisor);
And if the user types n
, the program exits, but if you type any other character, it appears, the same message asking you to perform a new test.
Code:
do {
printf("\nDeseja realizar novo teste (s/n) ?");
op = getche();
}while(getche() != 's' || getche != 'n');
It continues to run do-while
, even if I put the characters s
or n
, how can I make it work?