On Tue, 20 Jan 2004 01:49:44 -0500, Sanyi Benczik
<sbenczik@hotmail.com> wrote in comp.lang.c++:
[color=blue]
> Is there a way to obtain the name of the file associated with a fstream
> object?
>
> For example if I have
>
> using namespace std;
> ofstream file("test.txt");
>
> is there a function which evaluates to "test.txt"?
>
> Thx,
> Sanyi[/color]
There is no way to do this using standard C++. There might or might
not be a non-standard platform specific extension provided by your
compiler/OS combination. On some platforms, a single file may have
more than one name.
Of course you could always build an object that contained a
std::string with the name and a stream reference.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html