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

From: <silverdr1wfmh.org.pl>
Date: 2011-06-06 16:54:16
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 majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Jun 6 16:54:25 2011

This archive was generated by hypermail 2.1.8 : 2011-06-06 16:54:28 CEST