Obtain filename from file pointer in C [duplicate]

狂风中的少年 提交于 2019-11-29 14:21:58

I believe not, because a file* could be to something that doesn't even have a name. There might be a platform dependent way, depending I. Your system, so if you don't care about portability, try looking at your compiler's definition of FILE if it has one. Odds are that your only way is to save the name when it's opened.

There are some other potentially hacky ways as well- check this link:

http://bytes.com/topic/c/answers/218921-how-get-filename-file-pointer

Cheers!

See here for why this is hard, and can't be done in a portable way.

http://discuss.fogcreek.com/joelonsoftware5/default.asp?cmd=show&ixPost=179112

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!