need C help, passing char buffer[] by-value....
Gary Kline
kline at thought.org
Tue Oct 20 23:46:24 UTC 2009
On Mon, Oct 19, 2009 at 08:24:49PM -0700, Patrick Mahan wrote:
>
>
> Gary Kline wrote:
> >On Mon, Oct 19, 2009 at 11:09:19AM -0700, Patrick Mahan wrote:
> >>See comments interspaced below -
> >
> >
> > You've got it exactly right, Patrick. There were no "C" classes in
> > 1978--I taught myself. Obviously, not that well because I have
> > already dreaded pointers. ---Well, usually.
>
> You are welcome, glad to help.
>
> [examples snipped]
>
> >
> >
> > Your examples help a lot! Everything works except when there are
> > two or more tags on one line such as:
> >
> > <BODY BGCOLOR="#FFFFFF" LINK="#00FFFF" VLINK="#006633"><FONT
> > SIZE="4">
> >
> >
> > I think I see where is your skiptags--pointer arithematic
> > function--this can be
> > caught. Thanks much!
> >
>
> If I might make a suggestion. Make use of a case (switch) statement:
>
> switch(buf[c]) {
> case '<': /* start of tag, skip it if requested */
> if (skiptags) c = skiptag(&buf[c]);
> ...
>
> default: /* handle normal stuff */
> ...
> }
>
> Inside your while() statement.
It took me over half an hour of fumbling, until i understood that you meant the
"while (fgets(buf, sixeof buf, fpin))" if that's right. then i fumbled the
ball because i used your pointer example rather than the indexing-into method,
case 'B'.
Just a FWIW, But for middle-involved cases like this program--what? a couple k lines
long--when i get wedged like this, i almost always break it down into like a
main{
fgets()
}
THEN:
skiptags()
i didn't figure this 'keep it simple, Sire' paradigm until a few [7-9,10] years ago.
that's godawful late to learn new tricks. it's hard to understand 35 lines of code
in the midst of 2400 :_)
gary
>
> Good luck,
>
> Patrick
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
--
Gary Kline kline at thought.org http://www.thought.org Public Service Unix
http://jottings.thought.org http://transfinite.thought.org
The 7.31a release of Jottings: http://jottings.thought.org/index.php
More information about the freebsd-questions
mailing list