C print file path from FILE*
问题 FILE * fd = fopen ("/tmp/12345","wb"); If I have the variable fd , how can I print the file path ? (/tmp/12345) in Linux env. 回答1: There's no standard way to retrieve a pathname from a FILE * object, mainly because you can have streams that aren't associated with a named file ( stdin , stdout , stderr , pipes, etc.). Individual platforms may supply utilities to retrieve a path from a stream, but you'd have to check the documentation for that platform. Otherwise, you're expected to keep track