May as well toss in the assembler guy approach to the problem:
char SpaceSquash()
{
for (i = strlen(desc) - 1; i > 0; i--) {
if (desc[i-1] == ' ') {
if (desc[i] == ' ') {
strncpy(&desc[i], &desc[i+1], (strlen(desc)-i));
}
}
}
return 0;
}
SWS
On Tue, Jun 21, 2016 at 2:16 PM, Irrwahn <irrwahn@???> wrote:
> On Tue, 21 Jun 2016 17:55:52 +0100, Katolaz wrote:
> > On Tue, Jun 21, 2016 at 06:41:15PM +0200, Edward Bartolo wrote:
> >
> > [cut]
> >
> >>
> >> And
> >> << if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) >>
> >>
> >> would reduce to:
> >>
> >> if (isletter(c))
> >>
> >
> > or, you could just use "isalpha(c)", as suggested also by Urban.
>
> [Piggy-backing]
> And it would run much faster (all real-world implementations I
> am aware of use some sort of table lookup), and it'd take into
> account locale settings.
>
> Lesson: If you find yourself re-implementing a function from the
> Standard C Library (except for educational purposes), chances are
> you're doing it wrong.
>
> U.
> _______________________________________________
> Dng mailing list
> Dng@???
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
>