From: firewind Newsgroups: comp.os.msdos.djgpp Subject: Re: GCC TrimRight? Date: 1 Oct 1997 02:31:26 GMT Organization: Netcom Lines: 26 Message-ID: <60sclu$foq@dfw-ixnews8.ix.netcom.com> References: <60pd04$47k$1 AT flood DOT xnet DOT com> NNTP-Posting-Host: elp-tx2-10.ix.netcom.com Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Steve Laisch 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-." -]