need C help, passing char buffer[] by-value....

David Kelly dkelly at hiwaay.net
Mon Oct 19 03:23:58 UTC 2009


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 at HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.





More information about the freebsd-questions mailing list