The simple answer is "you cannot." There are no standard C ++ functions to control this behavior or to read data without falling into the end (in fact, the data was not actually entered until you hit enter, so the program will not see the data),
You can use non-standard functionality, such as additional libraries, such as a curse library or system code, but we will need to generate code to read characters one at a time and combine it together using the code that you write.
I would suggest that you use "repeat input on output" and just do something like this:
printf("%d is", d); if (d%2) printf("an odd number\n"); else printf("an even number\n");
source share