I am making a calculator where the user inputs something like, 'sum 3 4' and it would print '7'.
I have an infinite looping going and it scans for three things: a string and two ints. It all works except when you click enter, the terminal just makes a newline, and it keeps doing this until you enter something else. If you run it you'll see what I mean.
for (;;) {
    scanf("%20s", stringBuffer);
    scanf("%d ", &num1);
    scanf("%d ", &num2);
    if (strcmp(stringBuffer, "add") == 0) {
        printf("%d + %d = %d", num1, num2, (num1 + num2));
    } 
    else if (strcmp(stringBuffer, "sub") == 0) {
        printf("%d - %d = %d", num1, num2, (num1 - num2));
    }
    else if (strcmp(stringBuffer, "mul") == 0) {
        printf("%d * %d = %d", num1, num2, (num1 * num2));
    }
    else if (strcmp(stringBuffer, "div") == 0) {
        printf("%d / %d = %d", num1, num2, (num1 / num2));
    }
    else if (strcmp(stringBuffer, "help") == 0) {
        printf("input: operation n1 n2\n");
        printf("output: operation(n1, n2)\n");
        printf("implemented operations: 'add', 'sub', 'mul', and 'div'\n");
    }
    else if (strcmp(stringBuffer, "quit") == 0) {
        return 0;
    } else {
        printf("Please try again.\n");
    }
}
Any help towards a fix would be much appreciated.
