Date: Sun, 19 Feb 2006 02:17:48 +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: <20060219001748.GA62793@flame.pc> In-Reply-To: <43F784AA.50206@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> <43F76296.4010407@mac.com> <43F784AA.50206@voidmain.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2006-02-18 15:33, Tom Grove <freebsd@voidmain.net> wrote: >Chuck Swiger wrote: >>Tom Grove wrote: >>>Chuck Swiger wrote: >>[ ... ] >>>> 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! >>> >> >> Depending on what you'd like to do, GNU readline may be a fine >> solution to your situation. Otherwise, getch(stdin) with a bit of >> code to "cook" DEL/BS/CR/NL, or just use the getline port as you've >> already done. :-) > > Okay...I think I'm either an idiot or going slowly insane. I'll admit > I'm not the most savvy C programmer but the following code gives me an > error: > > ## Source File## > #include <stdio.h> > #include <readline/readline.h> > #include <readline/history.h> > > int main() { > char *line; > > line = readline("Test: "); > > return 0; > } > ##Source File## > > ##Error## > /var/tmp//ccqxIZxQ.o(.text+0x25): In function `main': > : undefined reference to `readline' > ##Error## You're missing an ``-lreadline'' option at the end of your build command. You may be interested to know that the BSDs have editline(3) too, a command-line editing library that supports at least `some' of the GNU readline features, but is BSD-licensed: % man editline
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060219001748.GA62793>