Re: [cc65] Input string routine for a line of data?

From: Joseph Rose <rose.joseph121yahoo.com>
Date: 2011-06-06 18:11:55
Both gets() and fgets() at first acccept my input but then, when I press Enter, ask for more input then do the same with the cursor indented.  I can always borrow the input routine from my dead adventure game.  BTW: I use cc65 v. 2.13.2.


From: "silverdr1wfmh.org.pl" <silverdr1wfmh.org.pl>
To: cc651musoftware.de
Sent: Monday, June 6, 2011 10:54 AM
Subject: Re: [cc65] Input string routine for a line of data?


On 2011-06-06, at 15:23, Joseph Rose wrote:

> gets() will work, right? 

I believe I gave you a reasonable example, which does not use gets().

> #include <stdio.h>
> 
> int main()
> {
>  char text[20];
>  fputs("enter some text: ", stdout);
>  fflush(stdout); /* http://c-faq.com/stdio/fflush.html */
>  fgets(text, sizeof text, stdin);
>  printf("text = \"%s\"\n", text);
>  return 0;
> }

You can try getting along with gets() if walking on a thin ice is your preference, of course.

The gets() function is equivalent to fgets() with an infinite n and a stream of stdin, [...].  It is the caller's responsibility to ensure that the input line, if any, is sufficiently short to fit in the string.

In any case, it is a question about C programming, not cc65 specifics.
-- 
SD!

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo1musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Jun 6 18:12:08 2011

This archive was generated by hypermail 2.1.8 : 2011-06-06 18:12:10 CEST