Contents Index Topic Contents | ||
Previous Topic: Path Functions Next Topic: PathAddExtension |
PathAddBackslash
LPTSTR PathAddBackslash( LPCTSTR lpszPath );Adds a backslash to the end of a string to create the correct syntax for a path. If the source path already has a trailing backslash, no backslash will be added.
- Returns the address of the NULL that terminates the string.
- lpszPath
- Address of the string that represents a path.
Example:
#include <windows.h> #include <iostream.h> #include "Shlwapi.h" void main( void ) { // String for path name without backslash. char buffer_1[] = "C:\\dir_name\\dir_name\\file_name"; char *lpStr1; lpStr1 = buffer_1; // String for path name with backslash. char buffer_2[] = "C:\\dir_name\\dir_name\\file_name\\"; char *lpStr2; lpStr2 = buffer_2; cout << "The original path string 1 is " << lpStr1 << endl; cout << "The modified path string 1 is " << PathAddBackslash(lpStr1) << lpStr1 << endl; cout << "\nThe original path string 2 is " << lpStr2 << endl; cout << "The modified path string 2 is " << PathAddBackslash(lpStr2) << lpStr2 << endl; } OUTPUT: --------- The original path string 1 is C:\dir_name\dir_name\file_name The modified path string 1 is C:\dir_name\dir_name\file_name\ The original path string 2 is C:\dir_name\dir_name\file_name\ The modified path string 2 is C:\dir_name\dir_name\file_name\
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.