I'm writing code where I need to get input without the user pressing ENTER. The code is basically that I need to get 4 numbers from 1-6 without the user pressing ENTER all in one line.
I tried doing so with getchar(), but it doesn't work.
How do I do that?
Here's that part of the code:
int p1 = 0;
int p2 = 0;
int p3 = 0;
int p4 = 0;
p1 = getchar() - 48;
p2 = getchar() - 48;
p3 = getchar() - 48;
p4 = getchar() - 48;
1234<Enter>. Aside: please replace the "magic number"48with'0'._getch()or_getche().