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

2009-10-20 Thread Gary Kline
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

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

2009-10-20 Thread Gary Kline
On Tue, Oct 20, 2009 at 05:42:41AM +0200, Polytropon wrote: > Just a little and quite formal side note: > > On Mon, 19 Oct 2009 11:09:19 -0700, Patrick Mahan wrote: > >while (*tp != '\0' && *tp++ != '<'); > > It's often a good choice, especially for increasing readability > of co

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

2009-10-20 Thread David Kelly
On Tue, Oct 20, 2009 at 05:42:41AM +0200, Polytropon wrote: > Just a little and quite formal side note: > > On Mon, 19 Oct 2009 11:09:19 -0700, Patrick Mahan wrote: > >while (*tp != '\0' && *tp++ != '<'); > > It's often a good choice, especially for increasing readability > of co

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

2009-10-20 Thread David Kelly
On Tue, Oct 20, 2009 at 05:08:40AM +0200, Polytropon wrote: > On Mon, 19 Oct 2009 08:58:05 -0500, David Kelly wrote: > > On Mon, Oct 19, 2009 at 05:43:44AM +0200, Polytropon wrote: > > > to make sure s is not NULL, or testing for it explicitely like > > > > > > if(!s) > > > ... error

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

2009-10-19 Thread Polytropon
On Mon, 19 Oct 2009 15:21:26 -0700, Gary Kline wrote: > There were no "C" classes in 1978--I > taught myself. Obviously, not that well because I have already dreaded > pointers. ---Well, usually. Don't mind. Just imagine my fun when trying to understand how character string operat

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

2009-10-19 Thread Polytropon
Just a little and quite formal side note: On Mon, 19 Oct 2009 11:09:19 -0700, Patrick Mahan wrote: >while (*tp != '\0' && *tp++ != '<'); It's often a good choice, especially for increasing readability of code, to code the "empty statement" on a line on its own (as you usually put

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

2009-10-19 Thread Patrick Mahan
Gary Kline wrote: On Mon, Oct 19, 2009 at 11:09:19AM -0700, Patrick Mahan wrote: See comments interspaced below - Gary, Let me restate your problem: You want to read through a file containing tags delimited by "<>" and to skip these tags if the user has run your command with the "-N" flag.

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

2009-10-19 Thread Polytropon
On Mon, 19 Oct 2009 08:58:05 -0500, David Kelly wrote: > On Mon, Oct 19, 2009 at 05:43:44AM +0200, Polytropon wrote: > > to make sure s is not NULL, or testing for it explicitely like > > > > if(!s) > > ... error handling here ... > > You are missing my point that *s == 0 is not

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

2009-10-19 Thread Gary Kline
On Mon, Oct 19, 2009 at 11:09:19AM -0700, Patrick Mahan wrote: > See comments interspaced below - > > Gary, > > Let me restate your problem: You want to read through a file containing tags > delimited by "<>" and to skip these tags if the user has run your command > with > the "-N" flag. > > In

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

2009-10-19 Thread Patrick Mahan
See comments interspaced below - Gary Kline wrote: On Mon, Oct 19, 2009 at 01:48:42AM -0400, Brad Mettee wrote: 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 '>'. [snipped]

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

2009-10-19 Thread Gary Kline
On Mon, Oct 19, 2009 at 01:48:42AM -0400, Brad Mettee wrote: > 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,

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

2009-10-19 Thread Gary Kline
On Mon, Oct 19, 2009 at 04:19:11PM +0200, Erik Trulsson wrote: > On Mon, Oct 19, 2009 at 09:03:22AM -0500, David Kelly wrote: > > On Sun, Oct 18, 2009 at 11:30:49PM -0400, Robert Huff wrote: > > > > > > Glen Barber writes: > > > > > > > > "//" comments are recognized by both C and C++. > > > >

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

2009-10-19 Thread Erik Trulsson
On Mon, Oct 19, 2009 at 09:03:22AM -0500, David Kelly wrote: > On Sun, Oct 18, 2009 at 11:30:49PM -0400, Robert Huff wrote: > > > > Glen Barber writes: > > > > > > "//" comments are recognized by both C and C++. > > > > How about "... are recognized by both C++ and more recent versions > >

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

2009-10-19 Thread David Kelly
On Sun, Oct 18, 2009 at 11:30:49PM -0400, Robert Huff wrote: > > Glen Barber writes: > > > > "//" comments are recognized by both C and C++. > > How about "... are recognized by both C++ and more recent versions > of C."? I think gcc++ and gcc use the same preprocessor? Comments are str

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

2009-10-19 Thread David Kelly
On Mon, Oct 19, 2009 at 05:43:44AM +0200, Polytropon wrote: > On Sun, 18 Oct 2009 22:23:43 -0500, David Kelly wrote: > > 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 b

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

2009-10-18 Thread Brad Mettee
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? An

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

2009-10-18 Thread Gary Kline
On Mon, Oct 19, 2009 at 04:02:29AM +0200, Polytropon wrote: > On Sun, 18 Oct 2009 18:33:43 -0700, 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

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

2009-10-18 Thread Gary Kline
On Mon, Oct 19, 2009 at 05:43:44AM +0200, Polytropon wrote: > On Sun, 18 Oct 2009 22:23:43 -0500, David Kelly wrote: > > 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 b

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

2009-10-18 Thread Polytropon
On Sun, 18 Oct 2009 23:30:49 -0400, Robert Huff wrote: > > Glen Barber writes: > > > >> // redo, skip TAGS > > > > > > Is this C or C++ source code? I always thought // was C++ > > > specific... > > > > > > > "//" comments are recognized by both C and C++. > > How about "... are r

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

2009-10-18 Thread Polytropon
On Sun, 18 Oct 2009 22:23:43 -0500, David Kelly wrote: > 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. There are means like #include

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

2009-10-18 Thread Robert Huff
Glen Barber writes: > >> // redo, skip TAGS > > > > Is this C or C++ source code? I always thought // was C++ > > specific... > > > > "//" comments are recognized by both C and C++. How about "... are recognized by both C++ and more recent versions of C."?

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

2009-10-18 Thread David Kelly
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 hand

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

2009-10-18 Thread Glen Barber
On Sun, Oct 18, 2009 at 10:02 PM, Polytropon wrote: [snip] > >> // redo, skip TAGS > > Is this C or C++ source code? I always thought // was C++ > specific... > "//" comments are recognized by both C and C++. -- Glen Barber ___ freebsd-questions@fre

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

2009-10-18 Thread Polytropon
On Sun, 18 Oct 2009 18:33:43 -0700, 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 h