This documentation is archived and is not being maintained.

_splitpath, _wsplitpath

Break a path name into components.

void _splitpath(
   const char *path,
   char *drive,
   char *dir,
   char *fname,
   char *ext 
void _wsplitpath(
   const wchar_t *path,
   wchar_t *drive,
   wchar_t *dir,
   wchar_t *fname,
   wchar_t *ext 


Full path
Optional drive letter, followed by a colon (:)
Optional directory path, including trailing slash. Forward slashes ( / ), backslashes ( \ ), or both may be used.
Base filename (no extension)
Optional filename extension, including leading period (.)


The _splitpath function breaks a path into its four components. _splitpath automatically handles multibyte-character string arguments as appropriate, recognizing multibyte-character sequences according to the multibyte code page currently in use. _wsplitpath is a wide-character version of _splitpath; the arguments to _wsplitpath are wide-character strings. These functions behave identically otherwise

Security Note    These functions incur a potential threat brought about by a buffer overrun problem. Buffer overrun problems are a frequent method of system attack, resulting in an unwarranted elevation of privilege. For more information, see Avoiding Buffer Overruns.

Generic-Text Routine Mappings

TCHAR.H routine _UNICODE & _MBCS not defined _MBCS defined _UNICODE defined
_tsplitpath _splitpath _splitpath _wsplitpath

Each argument is stored in a buffer; the manifest constants _MAX_DRIVE, _MAX_DIR, _MAX_FNAME, and _MAX_EXT (defined in STDLIB.H) specify the maximum size necessary for each buffer. The other arguments point to buffers used to store the path elements. After a call to _splitpath is executed, these arguments contain empty strings for components not found in path. You can pass a NULL pointer to _splitpath for any component you don't need.


Routine Required header Compatibility
_splitpath <stdlib.h> Win 98, Win Me, Win NT, Win 2000, Win XP
_wsplitpath <stdlib.h> or <wchar.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


See the example for _makepath.

See Also

File Handling Routines | _fullpath | _getmbcp | _makepath | _setmbcp | Run-Time Routines and .NET Framework Equivalents