Scanf and Conio

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Guest

Scanf and Conio

Post 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
Whatever5k

Re:Scanf and Conio

Post 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.).
Post Reply