Page 1 of 1

Scanf and Conio

Posted: Tue Dec 31, 2002 11:02 am
by Guest
Hey,
i was wonderin if neone could give me clues and ideas about how to go about writing the scanf function in c.
i would also like to now how to write the window function which is avalable in the conio.h, as i have already created the clrscr, textcolor, textbackground functions, but want to know how to make the window function.
thnx for ur help

Re:Scanf and Conio

Posted: Tue Dec 31, 2002 11:15 am
by Whatever5k
Implementing scanf() requires a terminal driver. When a user calls scanf(), it will generate a system call (READ from stdin). The job of your terminal driver is to get the keys written by the users. But it doesn't just poll the keyboard, but the keys pressed by the user are put in a linked list (on every keyboard interrupt). So your terminal driver takes the keys from the list and returns it to the user.
This is a very simple terminal driver. You should probably google around - for example, there are different terminal modes (cooked mode, etc.).