Date: Sat, 18 Feb 2006 20:20:31 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Tom Grove <freebsd@voidmain.net> Cc: freebsd-questions@freebsd.org Subject: Re: getline function Message-ID: <20060218182031.GA2653@flame.pc> In-Reply-To: <43F75F3C.7080903@voidmain.net> References: <43F68C7D.9010403@voidmain.net> <1140233843.982.21.camel@chaucer.jeays.ca> <43F74361.90109@voidmain.net> <43F75DF6.3050903@mac.com> <43F75F3C.7080903@voidmain.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2006-02-18 12:54, Tom Grove <freebsd@voidmain.net> wrote: >Chuck Swiger wrote: >>Tom Grove wrote: >>>Mike Jeays wrote: >>> That works and I had looked into that earlier...it seems like >>> it does a lot more than just one function from the man page. >>> I guess I can use that for now but I wonder why getline() is >>> broken in gcc on FreeBSD? >> >> getline() is not part of the standard C library. >> What makes you think gcc is broken...? > > Yeah...I see that after some more research. So, now I guess my > question is being that it's not standard and gets() is not safe > to use what should I use to grab lines? My gut tells me to > copy the getline() function from the K&R book but I'm not > totally sure that's a great idea either. Stupid strings always > causing problems! This is a frequently recurring question in comp.lang.c. There are perfectly portable ways to use only ANSI C functions to read a full line of text, allocating dynamically as much memory as needed. For example, a search in the archives of the newsgroup will provide easily pointers to safe ways to use fgets() to read a line.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060218182031.GA2653>