Re: how to get the file name



marsarden wrote:
only has the FILE * handle , how to get the file name ?

for example,i have a function accpet a (FILE *)argumment and return the
file name : char * getfilename(FILE * fp);
You cannot.
Remember the filename when you opened it, if you can.

(though linux has some not always reliable way, get
the filedescriptor with the fileno() function ,
call the readlink function on the /proc/self/fd/<fd>
fd file. Do a ls -l /proc/self/fd to see what it's about)
.