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?
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.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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.Originally Posted by umen242
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.