> On January 25, 2016 at 7:40 AM KatolaZ <kato...@freaknet.org> wrote:
> 
> 
> On Mon, Jan 25, 2016 at 12:23:01PM +0000, Rainer Weikusat wrote:
> > KatolaZ <kato...@freaknet.org> writes:
> > 
> > [...]

 [...]

> > The program also contains a very nice example of why the post-increment
> > operators is useful (and I means 'useful', not 'common because of
> > mindless copying of example code'):
> > 
> > static char const *get_name(char const *arg0)
> > {
> >     char const *n, *r;
> > 
> >     n = r = arg0;
> >     while (*r) if (*r++ == '/') n = r;
> >     return n;
> > }
> 
> That's pretty straight-forward C-programming, IMHO, but I agree that
> it could be seen as interesting by a mor^H^H^Hstudent who approaches C
> for the first time.
> 
> Peace, love and hacking.
> 
> KatolaZ

This also brings up the question of whether you should roll your own get_name or
use basename(3) which already does the same thing except in some edge cases.
 It's easier for the student to understand the code if it is implemented as
get_name, but the student ought to learn about dirname and basename pretty early
in their study.

Peter Olson
_______________________________________________
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to