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?
This is a discussion on how can i get the ofstream file name within the C++ Programming forums, part of the General Programming Boards category; Hello all it seams to be beginners question , but do i have the possibility to get the file name ...
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.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
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
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
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.