4

[SOLVED] How to get the full path of a file in C?

view full story
linux-howto

http://www.linuxquestions.org – Is there a way to get the full path of a file in C? I have a method that accepts a file name as an argument and is supposed to read the content of the file. The file name might include "../" so this might lead to accessing files outside of the current directory. I tried to use fstat but I could not figure out how to get the full path. Code: void readFile(char *filename) {         FILE *fp;         //char filename[] = "../../debug.log";         fp = fopen(filename, "r");         if (HowTos)