delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/03/16:37:34

Message-ID: <0339D548AB08D31182040000F8BCBAF9074B1B9B@exchange.atlantaga.ncr.com>
From: "Hunt, David" <dh210008 AT Exchange DOT AtlantaGA DOT NCR DOT com>
To: djgpp AT delorie DOT com
Subject: Re: fgets Max Chars
Date: Thu, 3 Aug 2000 16:37:08 -0400
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Reply-To: djgpp AT delorie DOT com

To answer your question more directly, the BIOS of your machine limits the
number of input characters for string input to 128.  It is the BIOS that
buffers the input and passes that kbd input to stdio.  After 128 characters
the beep is being returned to you without anything being passed on to the
program.

dh


Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote in message
news:<Pine DOT SUN DOT 3 DOT 91 DOT 1000730105642 DOT 23058B-100000 AT is>...
> 
> On Sat, 29 Jul 2000, Paulo J. Matos aka PDestroy wrote:
> 
> > #include <stdio.h>
> > 
> > int main(void) {
> >     char *s;
> > 
> >     s=malloc(3000);
> > 
> >     fgets(s, 3000, stdin);
> >     return 1;
> > }
> > 
> > Althought I malloced 3000 chars I am only able to write 129...
> 
> Modify your program like shown below, and it will do what you expect.
> 
> (Although generally a good idea, tcflush is not really needed in the
> particular case of this simple test program.  I used it because it
> causes termios to kick in and handle console input, instead of DOS.
> This works around the limitations of the DOS console device driver.)
> 
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <termios.h>
>  
>  int main(void) {
>      char *s;
>  
>      s=malloc(3000);
>  
>      tcflush(fileno(stdin), TCIFLUSH);
>      fgets(s, 3000, stdin);
>      return 1;
>  }
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019