StrTrim function
Removes specified leading and trailing characters from a string.
Syntax
BOOL StrTrim( _Inout_ PTSTR psz, _In_ PCTSTR pszTrimChars );
Parameters
- psz [in, out]
-
Type: PTSTR
A pointer to the null-terminated string to be trimmed. When this function returns successfully, psz receives the trimmed string.
- pszTrimChars [in]
-
Type: PCTSTR
A pointer to a null-terminated string that contains the characters to trim from psz.
Return value
Type: BOOL
TRUE if any characters were removed; otherwise, FALSE.
Examples
#include <windows.h> #include <iostream.h> #include "Shlwapi.h" void main(void) { //String one TCHAR buffer[ ] = TEXT("_!ABCDEFG#"); TCHAR trim[ ] = TEXT("#A!_\0"); cout << "The string before calling StrTrim: "; cout << buffer; cout << "\n"; StrTrim(buffer, trim); cout << "The string after calling StrTrim: "; cout << buffer; cout << "\n"; } OUTPUT: - - - - - - The string before calling StrTrim: _!ABCDEFG# The string after calling StrTrim: BCDEFG
Requirements
|
Minimum supported client |
Windows 2000 Professional, Windows XP [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names |
StrTrimW (Unicode) and StrTrimA (ANSI) |