Click here to Skip to main content
Licence CPOL
First Posted 20 May 2003
Views 61,277
Downloads 801
Bookmarked 13 times

XTrim - trim leading and trailing whitespace characters

By | 20 May 2003 | Article
XTrim implements _tcsltrim and _tcsrtrim - CRT-like functions to trim whitespace.

Introduction

XTrim implements _tcsltrim and _tcsrtrim, non-MFC functions to trim whitespace from a string.

Function Descriptions

  • _tcsltrim() - Remove leading whitespace.
    ///////////////////////////////////////////////////////////////////////////////
    //
    // _tcsltrim()
    //
    // Purpose:     Removes (trims) leading whitespace characters from a string
    //
    // Parameters:  pszSource - Pointer to the null-terminated string to be trimmed.
    //                          On return, pszSource will hold the trimmed string
    //
    // Returns:     TCHAR *   - pointer to trimmed string
    // 
  • _tcsrtrim() - Remove trailing whitespace.
    ///////////////////////////////////////////////////////////////////////////////
    //
    // _tcsrtrim()
    //
    // Purpose:     Removes (trims) trailing whitespace characters from a string
    //
    // Parameters:  pszSource - Pointer to the null-terminated string to be trimmed.
    //                          On return, pszSource will hold the trimmed string
    //
    // Returns:     TCHAR *   - pointer to trimmed string
    // 

How To Use

To integrate XTrim functions into your app, you first need to add following files to your project:

  • XTrim.cpp
  • XTrim.h

If you include XTrim in project that uses precompiled headers, you must change C/C++ Precompiled Headers settings to Not using precompiled headers for XTrim.cpp.

Next, include the header file XTrim.h in appropriate project files. Now you are ready to start using XTrim. Please see XTrimTest.cpp for examples.

Revision History

Version 1.0 - 2003 May 11

  • Initial public release

Usage

This software is released into the public domain. You are free to use it in any way you like. If you modify it or extend it, please to consider posting new code here for everyone to share. This software is provided "as is" with no expressed or implied warranty. I accept no liability for any damage or loss of business that this software may cause.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Hans Dietrich

Software Developer (Senior)
Hans Dietrich Software
United States United States

Member

I attended St. Michael's College of the University of Toronto, with the intention of becoming a priest. A friend in the University's Computer Science Department got me interested in programming, and I have been hooked ever since.
 
Recently, I have moved to Los Angeles where I am doing consulting and development work.
 
For consulting and custom software development, please see www.hdsoft.org.







Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralOverCombination... PinmemberNitager9:58 4 Jan '09  
GeneralBugs and slow performance PinsussRobert F9:15 20 Sep '04  
GeneralThe joke's on me. PinmemberWREY21:04 17 Oct '03  
GeneralTwo byte space characters PinmemberTQN17:57 21 May '03  
GeneralRe: Two byte space characters PinmemberHans Dietrich19:45 21 May '03  
GeneralRe: Two byte space characters PinmemberEIEN19:13 27 May '03  
GeneralRe: Two byte space characters Pinmembersachintha8114:57 17 Aug '08  
GeneralRe: Two byte space characters PinmemberEIEN16:48 17 Aug '08  
GeneralRe: Two byte space characters Pinmembersachintha8118:06 17 Aug '08  
GeneralRe: Two byte space characters Pinmembersachintha8118:59 17 Aug '08  
GeneralRe: Two byte space characters PinmvpHans Dietrich19:14 17 Aug '08  
GeneralRe: Two byte space characters Pinmembersachintha8119:58 17 Aug '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 20 May 2003
Article Copyright 2003 by Hans Dietrich
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid