Using _fullpath() function


Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows XP Pro SP2

Header file: Standard

Additional library: none/default

Additional project setting: Set project to be compiled as C

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C Code (/TC)

Other info: none

To do: Displaying the full path

To show: Using _fullpath()




#include <stdio.h>

#include <conio.h>

#include <stdlib.h>

#include <direct.h>


void DisplayFullPath(char *relPath)


/* Buffer */

char full[_MAX_PATH];


if(_fullpath(full, relPath, _MAX_PATH) != NULL)

printf("The full path is: %s\n", full);


printf("Invalid path.\n");



int main(void)





return 0;



Output example:


The full path is: f:\vc2005project\cplus\cplus\test.txt

The full path is: f:\test.txt

The full path is: f:\vc2005project\cplus\test.txt

Press any key to continue . . .



C and C++ Programming Resources | C & C++ Code Example Index