@Jochen
Hi jj!
Much, much better your solution , and my only excuse
(a pathetic but a true one) is I did not know this api.
However...your:
if ((getchar() & 2) == 2)
is wrong, the correct one is
if (getchar() == 50) or if (getchar() == '2')
Is wrong because :
#include <stdio.h>
int main(void)
{
for (int i = 0; i < 256; i++)
{
int a = i & 2;
if (a == 2)
printf("keyboard decimal = %i (0x%.2x)\tchar = \'%c\'\t(%i & 2) = %i\tpas the test\n", i, i, i < 0x07 || i > 0x0d ? i : ' ', i, a);
else
printf("keyboard decimal = %i (0x%.2x)\tchar = \'%c\'\t...\n", i, i, i < 0x07 || i > 0x0d ? i : ' ');
}
}
Laur