From: Keith MARSHALL <keith.marshall@to...> - 2005-01-14 09:48:29
Gisle Vanem wrote:
> Maybe I wasn't clear; I need to write an *interactive* version of
> I.e. with my own getchar() replacement with echo. This is for a little
> conio library (Borland style if anybody remembers that). So feeding a
> buffer to fscanf/sscanf cannot be interactive AFAICS. Code like
> rc = my_scanf ("%d",val);
> should terminate on 1st non-digit returned from my input function.
Why do you need to hook a custom input routine into scanf?
Would it not be better to write a separate getch() based capture routine,
save the input in your own buffer, and then parse that using sscanf(),
(or, indeed, any of the other string-to-numeric conversion functions)?
That way, you can do whatever you want in the input routine, without
worrying about the internal workings of scanf.