Why scanf(“%d”, […]) does not consume ‘\n’? while scanf(“%c”) does?
It is consistent behavior, you’re just thinking about it wrong. 😉 scanf(“%c”, some_char); // reads a character from the key board. scanf(“%d”, some_int); // reads an integer from the key board. So if I do this: printf(“Insert a character: “); scanf(“%c”, &ch); // if I enter ‘f’. Really I entered ‘f’ + ‘\n’ // scanf … Read more