Syntax
#include <stdlib.h> void _makepath(char *path, char *drive, char *dir, char *fname, char *ext);Description
The path argument should point to an empty buffer large enough to hold the complete path name. The constant _MAX_PATH, defined in <stdlib.h>, specifies the maximum size allowed for path. The other arguments point to the following buffers containing the path name elements:
drive
The size limits on the above four fields are those specified by the constants _MAX_DRIVE, _MAX_DIR, _MAX_FNAME, and _MAX_EXT, which are defined in <stdlib.h>. The composite path should be no larger than the _MAX_PATH constant also defined in <stdlib.h>; otherwise, the operating system does not handle it correctly.
Note: No checking is done to see if the syntax of the file name is correct.
There is no return value.
This example builds a file name path from the specified components:
#include <stdio.h>#include <stdlib.h>
int main(void)
{
char path_buffer[_MAX_PATH];
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_makepath(path_buffer, "c", "qc\\bob\\eclibref\\e", "makepath", "c");
printf("Path created with _makepath: %s\n\n", path_buffer);
_splitpath(path_buffer, drive, dir, fname, ext);
printf("Path extracted with _splitpath:\n");
printf("drive: %s\n", drive);
printf("directory: %s\n", dir);
printf("file name: %s\n", fname);
printf("extension: %s\n", ext);
return 0;
/****************************************************************************
The output should be:
Path created with _makepath: c:qc\bob\eclibref\e\makepath.c
Path extracted with _splitpath:
drive: c:
directory: qc\bob\eclibref\e\
file name: makepath
extension: .c
****************************************************************************/
}
Related Information