How can I convert a relative path to an absolute path in C on Unix? Is there a convenient system function for this?
On Windows there is a GetFullPathName
GetFullPathName
Try realpath() in stdlib.h
realpath()
stdlib.h
char filename[] = "../../../../data/000000.jpg"; char* path = realpath(filename, NULL); if(path == NULL){ printf("cannot find file with name[%s]\n", filename); } else{ printf("path[%s]\n", path); free(path); }