Ensure that input buffer is cleared before scanf()

main
sgoudham 3 years ago
parent 03251e0fc7
commit b23e016509

@ -9,6 +9,7 @@ int main() {
do { do {
printf("Enter An Operator (+, -, *, /):\nEnter 'e' To Exit:\n"); printf("Enter An Operator (+, -, *, /):\nEnter 'e' To Exit:\n");
scanf(" %c", &operator); scanf(" %c", &operator);
while (getchar() != '\n');
if (operator == 'e') { if (operator == 'e') {
break; break;

Loading…
Cancel
Save