Didier Kryn <kryn@???> writes:
> Le 25/01/2016 19:11, Rainer Weikusat a écrit :
>> Didier Kryn <kryn@???> writes:
>>
>> [...]
>>
>>>> A multi-line version could look like this:
>>>>
>>>> while (c = *r) {
>>>> ++r;
>>>> if (c == '/') n = r;
>>>> }
>>>>
>>> It might be done with a for loop. eg:
>>>
>>> for ( ; *r ; ++r) if(*r=='/') n=r;
>>> n++;
>> [...]
>>
>>> The for loop is the best construct for a loop with an incremental
>>> cursor.
>> That's nicely exemplified by the fact that the code above does a
>> redundant increment (or did a redundant increment would it work, the {}
>> are missing)
> There needs only be one increment of n at the end of the loop,
> but, maybe it should be:
> if(n) n++;
> because I guess n starts from 0.
It could be
if (n > arg0) ++n;
or
n += n > arg0;
if one desires to get fancy, as arg0 doesn't necessarily start with a
'/' but that's still a correction necessary because the loop code sets n
to a value known to be wrong.