Format
#include <stdlib.h> char *_fullpath(char *pathbuf, char *partialpath, size_t n);
Language Level: Extension
_fullpath gets the full path name of the given
partial path name partialpath,
and stores it in pathbuf.
The integer argument n
specifies the maximum length for the path name. An error occurs
if the length of the path name, including the terminating null
character, exceeds n characters.
If pathbuf is NULL, _fullpath uses malloc to allocate a buffer of size _MAX_PATH bytes to store the path name.
Return Value
_fullpath returns a pointer to pathbuf. If an error
occurs, _fullpath returns NULL and sets errno to one of the
following values:
| Value | Meaning |
| ENOMEM | Unable to allocate storage for the buffer. |
| ERANGE | The path name is longer than n characters. |
| EOS2ERR | A system error occurred. Check _doserrno for the specific OS/2 or Windows code. |
Example
This example uses _fullpath to get and
store the full path name of the current directory.
#include <stdio.h> #include <stdlib.h> #include <errno.h>
int main(void)
{
char *retBuffer;
retBuffer = _fullpath(NULL, ".", 0);
if (NULL == retBuffer) {
printf("An error has occurred, errno is set to %d.\n", errno);
}
else
printf("Full path name of current directory is %s.\n", retBuffer);
return 0;
/********************************************************************
The output should be similar to:
Full path name of current directory is D:\BIN. ********************************************************************/ }
![]()
_getcwd -- Get Path Name of
Current Directory
_getdcwd -- Get
Full Path Name of Current Directory
_makepath --
Create Path
malloc --
Reserve Storage Block
_splitpath --
Decompose Path Name
<stdlib.h>