From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-11-21 19:09:33
On Fri, Nov 21, 2003 at 12:19:46PM -0500, Raj Wurttemberg wrote: > What is the alternative for the following statement in cc65:? > > scanf("%d", &num); > > I found it in stdio.h but it was... > > /* Not available or testing: */ > int scanf (const char* format, ...); The guts of all the scanf functions exist, but they cannot work on files, since the current file implementation has no working ungetc(). An alternative is to use sscanf, which works on strings: char buf [64]; int foo; if (fgets (buf, sizeof (buf), stdin) != 0) { sscanf (buf, "%d", &foo); } else { Error ("Cannot read from stdin!"); } BTW: fgets seems to be broken in the snapshot, but above code works with 2.9.3. 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 : 2003-11-21 19:09:47 CET