From owner-freebsd-questions@FreeBSD.ORG Mon Oct 19 03:23:58 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5FE8E1065672 for ; Mon, 19 Oct 2009 03:23:58 +0000 (UTC) (envelope-from dkelly@hiwaay.net) Received: from smtp.knology.net (smtp.knology.net [24.214.63.101]) by mx1.freebsd.org (Postfix) with ESMTP id E19878FC0C for ; Mon, 19 Oct 2009 03:23:57 +0000 (UTC) Received: (qmail 27904 invoked by uid 0); 19 Oct 2009 03:23:55 -0000 Received: from unknown (HELO ?10.0.0.9?) (24.42.224.110) by smtp1.knology.net with SMTP; 19 Oct 2009 03:23:55 -0000 References: <20091019013337.GA9522@thought.org> In-Reply-To: <20091019013337.GA9522@thought.org> Mime-Version: 1.0 (Apple Message framework v1076) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Message-Id: <72213BBF-5E05-430D-BF9A-FCD2666951C6@hiwaay.net> Content-Transfer-Encoding: 7bit From: David Kelly Date: Sun, 18 Oct 2009 22:23:43 -0500 To: Gary Kline X-Mailer: Apple Mail (2.1076) Cc: FreeBSD Mailing List Subject: Re: need C help, passing char buffer[] by-value.... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2009 03:23:58 -0000 On Oct 18, 2009, at 8:33 PM, Gary Kline wrote: > Guys, > > maybe this can't be done reading in a file with fgets(buffer[128], > fp), > then calling skiptags(), conditionally, to while () past ',' and '>'. > > I know I need to calll skipTags with its address, skipTags > (&buffer);, but then how to i > handle the variable "s" in skipTags? Anybody? The skipTags() you wrote doesn't return its result. Without actually trying it I think this will work: // redo, skip TAGS char *skipTags( char *s ) { if( *s == '<' ) { while( *s && ( *s++ != '>' ) ) ; // on a line of its own to make sure you see it } return s; } When not using a count to indicate how much data is in a char* you should always test for null. Testing for null is not a sure fire way to prevent buffer over runs but its better than nothing. Use the above something like this: char *buffPtr; buffPtr = skipTags( buffPtr ); // advance over < > tags -- David Kelly N4HHE, dkelly@HiWAAY.net ======================================================================== Whom computers would destroy, they must first drive mad.