Re: [cc65]user input

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2001-03-05 08:14:49


Hi!

On Sun, Mar 04, 2001 at 10:47:08PM -0500, troy silvey wrote:
> Following your conio.h advice Ullrich, I came up with
> this bit of code for entering user data....

A few suggestions regarding your code:

  * Use cprintf instead of printf. If you're doing console I/O anyway, the
    former is faster and works on all platforms (printf is file I/O,
    remember? :-)

  * Using ++get instead of get++ will sometimes generate better code. It's not
    as bad as it used to be, especially with simple variables, but with more
    complex expressions like

       	a[3]++;

    this becomes an issue.

  * The last assignment in your function is unnecessary, since the value
    in pickit is not used any more:

       	return((pickit=atoi(store)));

  * The "store" string variable is not zero terminated, so atoi may return
    wrong values. Since there are only 10 digits and 255 possible character,
    your chance for this to happen is 10:245 :-)

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.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:39 CET