Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Jun 1999 15:47:49 -0700 (PDT)
From:      Steve Kargl <sgk@troutmask.apl.washington.edu>
To:        freebsd-ports@freebsd.org
Subject:   recommended gets() handling?
Message-ID:  <199906082247.PAA31922@troutmask.apl.washington.edu>

next in thread | raw e-mail | index | archive | help
I'm in the process of porting vis5d to freebsd.  It makes
use of the gets() function (which of is not a good thing).
What is the recommended method in changing gets() to fgets()?

Should

int func() {
  char s[1000];
  gets(s);
  /* more stuff */  
}
	
become

#ifdef __FreeBSD__
#define NUM  1000
#endif

int func() {
#ifdef __FreeBSD__
  char s[NUM];
  fgets(s, NUM - 1, stdin);
  s[strlen(s)] = '\0';
#else
  char s[1000];
  gets(s);
#endif
  /* more stuff */
}



-- 
Steve


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199906082247.PAA31922>