Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Oct 2009 22:23:43 -0500
From:      David Kelly <dkelly@hiwaay.net>
To:        Gary Kline <kline@thought.org>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: need C help, passing char buffer[] by-value....
Message-ID:  <72213BBF-5E05-430D-BF9A-FCD2666951C6@hiwaay.net>
In-Reply-To: <20091019013337.GA9522@thought.org>
References:  <20091019013337.GA9522@thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help

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.






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?72213BBF-5E05-430D-BF9A-FCD2666951C6>