get name of FILE* in c

closed account (Dy7SLyTq)
so i have an array of files stored in a FILE* and need to check if they exist. if they dont, i want to print an error, but i dont know how to get the name which i want for the error message
Which name? Do you mean the format of the error message?
Last edited on
closed account (Dy7SLyTq)
the name of the file which FILE* interfaces with
Why are you using C FILE * when you could be using C++ file streams or, better yet, Boost?
A FILE* doesn't necessarily map to a file (example: stdout) and therefore may not have a "name". So I'm pretty sure there's no way to get the filename from a FILE*.
There's ways to get it in windows and linux according to these answers http://stackoverflow.com/questions/4305355/how-get-filename-having-file
I don't think there's a portable way of doing this.
closed account (Dy7SLyTq)
Why are you using C FILE * when you could be using C++ file streams or, better yet, Boost?

im doing it in c/assembly. its good learning. there was a lot that i took for granted and didnt realize (like function overloading)

A FILE* doesn't necessarily map to a file (example: stdout) and therefore may not have a "name". So I'm pretty sure there's no way to get the filename from a FILE*.
good to know thanks.

@lachlan thanks ill take a look
Topic archived. No new replies allowed.