Hello all
it seams to be beginners question , but do i have the possibility to get the
file name i set in the ofstream constructor?
Printable View
Hello all
it seams to be beginners question , but do i have the possibility to get the
file name i set in the ofstream constructor?
Considering that you set it, obviously you know it, so you just need to save it.
i meant ou tof the ofstream variable
if i have
ofstream file("foo.txt")
how can i get from file variable the "foo.txt" string
You cannot do that.Quote:
Originally Posted by umen242
You could of course define your own class that stores the name of the file before opening an ofstream, and then make a ofstream cast-operator that returns the actual ofstream.
But there is absolutely no standard way to get the filename out of a stream, and I know of no implementation of file-streams that actually store the filename as part of the stream object.
--
Mats