From owner-freebsd-questions@FreeBSD.ORG Sat Feb 18 20:34:07 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CF9C416A420 for ; Sat, 18 Feb 2006 20:34:07 +0000 (GMT) (envelope-from freebsd@voidmain.net) Received: from pgh.nepinc.com (pgh.nepinc.com [66.207.129.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 153E343D4C for ; Sat, 18 Feb 2006 20:34:05 +0000 (GMT) (envelope-from freebsd@voidmain.net) Received: from [192.168.1.108] (monrovll-cuda1-69-164-173-96.pittpa.adelphia.net [69.164.173.96]) (authenticated bits=0) by pgh.nepinc.com (8.12.11/8.12.11) with ESMTP id k1IKY4Gr095454; Sat, 18 Feb 2006 15:34:04 -0500 (EST) (envelope-from freebsd@voidmain.net) Message-ID: <43F784AA.50206@voidmain.net> Date: Sat, 18 Feb 2006 15:33:46 -0500 From: Tom Grove Organization: VoidMain.net User-Agent: Thunderbird 1.5 (X11/20060210) MIME-Version: 1.0 To: Chuck Swiger 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> In-Reply-To: <43F76296.4010407@mac.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: getline function X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd@voidmain.net List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Feb 2006 20:34:07 -0000 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 #include #include 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## What sucks is that readline() seems like it would be the perfect solution. I'm not doing anything special but my I don't want to start getting into bad habits like using gets(). -Tom