How to get the full path just by specifying the file name?

Please help, I am not getting how to implement a function that returns the full path to this file using C / C ++?

+6
source share
1 answer

UNIX / Linux:

#include <limits.h> #include <stdlib.h> char *full_path = realpath("foo.dat", NULL); ... free(full_path); 

or

 char full_path[PATH_MAX]; realpath("foo.dat", full_path); 

Window:

 #include <windows.h> TCHAR full_path[MAX_PATH]; GetFullPathName(_T("foo.dat"), MAX_PATH, full_path, NULL); 
+11
source

Source: https://habr.com/ru/post/978988/


All Articles