Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_splitpath() split path name into components</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _splitpath()            Split Path Name into Components

 #include   <stdlib.h>

  void _splitpath( path, drive, dir, fname, ext);
  char *path;  Full path name buffer
  char *drive; Drive letter
  char *dir;   Directory path
  char *fname; File name
  char *ext;   File extension

    _splitpath() splits a full MS-DOS path name into the component
    arguments. The path argument should point to a buffer holding the
    complete path name.

    The manifest constant _MAX_PATH (defined in stdlib.h) specifies the
    maximum size path that MS-C can handle. The constants _MAX_DRIVE,
    _MAX_DIR, _MAX_FNAME, and _MAX_EXT specify the maximum size of the
    component arguments.

    The component arguments are returned in the following buffers:

    Buffer    Description
    ------    -----------------------------------------------
    drive     Contains the drive letter (A, B, C, etc.) followed
              by a colon if a drive is specified in path.

    dir       Contains path of directories, if any, including
              the trailing slash.

    fname     Contains the base file name without any
              extensions.

    ext       Contains the filename extension, if any, including
              the leading period.

    The return buffers will contain empty strings for any path components
    missing from path.

   Portability:     MS-DOS only

 -------------------------------- Example ---------------------------------

 This program extracts individual components from a combined path name

           #include <stdlib.h>

           main()
           {
              char drive[_MAX_DRIVE + 1];
              char dir[_MAX_DIR + 1];
              char fname[_MAX_FNAME + 1];
              char ext[_MAX_EXT + 1];

              _splitpath( "c:\\msc\\include\\stdio.h", drive, dir, fname,
           ext);
              printf("\tDrive = %s\n", drive);
              printf("\tDir   = %s\n", dir);
              printf("\tFname = %s\n", fname);
              printf("\tExt   = %s\n", ext);
           }


See Also: _makepath()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson