Mail Archives: djgpp/1997/10/02/01:00:40
Steve Laisch <slaisch AT typhoon DOT xnet DOT com> wrote:
> In Visual Basic and Visual C++/MFC their is a useful
> command called TrimRight() which will take a string and
> trim all the whitespace off the right side of the string.
> Atleast _I_ think its useful :-) Is their anything similiar
> in regular ANSI C in DJGPP? I'm not even sure if GXX(C++) has
> anything like it but I need a C counterpart and all my
> C texts before 1987 don't have one(Yes, I need to buy
> books more often :-)
Find the end of the string (marked by '\0') and go backwards from there,
moving the '\0' to the left one space if the character there is whitespace.
(Assuming p is a char *, save the original value cause p will not point to
the beginning of the string after this)
while(*p != '\0') p++;
while(isspace(*--p)) *p = '\0';
late\fw
--
[- firewind -]
[- email: firewind AT metroid DOT dyn DOT ml DOT org (home), firewind AT aurdev DOT com (work) -]
[- "You're just jealous because the voices talk to -me-." -]
- Raw text -