:: Re: [DNG] Icerbergs aren't small ju…
Pàgina inicial
Delete this message
Reply to this message
Autor: Peter Olson
Data:  
A: KatolaZ
CC: dng
Assumpte: Re: [DNG] Icerbergs aren't small just because they're mostly underwater (was: "Common knowledge?"-question)


> On January 25, 2016 at 7:40 AM KatolaZ <katolaz@???> wrote:
>
>
> On Mon, Jan 25, 2016 at 12:23:01PM +0000, Rainer Weikusat wrote:
> > KatolaZ <katolaz@???> 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