From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2000-02-06 10:52:26
> I wrote a program which it needed a scanf instruction. I think this > instruction is missing from library. This is correct. It is documented in doc/library.txt. I'm not sure if implementing scanf would really make sense, since it is a large function, even larger than printf, which is about 4K(!). > Instead I tried to use gets() and > convert it with atoi. But it did not work properly. [RETURN] must be > pressed twice and value returned was only one digit. I did not try all > the alternatives available (getchar() etc.). This is because the underlying function (read()) is a hack. It throws away the file descriptor and calls BASIN to get characters. File I/O (and gets is a file I/O function) does not work in the current version. Apart from that, it's a bad idea to use scanf, gets or any such function for user input. It is like using the BASIC INPUT command: You cannot control the input, and the user may even use the cursor keys to move the cursor elsewhere on the screen. > I wanted to ask you first > about this. What should I use for numeric input in my programs? For most text mode programs, the conio library is what you want to use. It does not offer a complete line input routine, but it has all you need to write it yourself: Direct input from the keyboard and direct output to the screen. The debugger module (lib/dbg/dbg.c) has such a routine that accepts a hexadecimal address input, and controls what the user is allowed to type. You may use it as a sample for your own stuff. Writing your own input routine is a bit (not much) more work than just using scanf, but your programs look much more professional, if you do. Regards Uz -- Ullrich von Bassewitz uz_at_musoftware.de ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:35 CET