I think that just with the out flag, you're trying to use trunc for the wrong type (std::ofstream).
Consider that by default std::ofstream behaves as if it gets ios::out | ios::trunc, and use the out and trunc flags only where they are truly needed. For example, std::fstream.
I understand you are probably confused by how it doesn't give you a warning or an error, but that's how C++ is. In this case you're not doing anything wrong, by giving it its implicit flags... but did you notice you can give std::ofstream the in flag?
I think it only applies to file systems streams however. ios::out and ios::trunc live within the ios namespace (rerouted, I believe) and can be accepted by all standard input/output objects. I believe I read something about there being support for a printer stream (don't remember where that was at) so those flags might behave differently than they do with file objects. It would be interesting to see how far you can dig.
I won't dig any more my friend ! It's just that I try to understand something with details...
That's why I decided to ask in this site, that you know things in C++ better than me !!
Thanks all of you for your support and help !
Soon I will "disturb" you with other difficulties in C++. One of them is "volatile", but I have to re-search for this first and I will open for this, another thread in this forum...
Thanks again all of you friends !!
Friend Catfish2, very interesting the code you are writing...
I will study it line-by-line ... By the way what compiler do you prefer ?
I use g++ & qtcreator because I love linux....
I started Qt GUI Programming 5 months ago, but I stopped to learn some details in nongui-C++...
In 2 months I will continue the Qt.
Maybe in 10 years I will reach your abilities in C++ By the way what C++gui do you prefer ?
Stroustrup suggested a lot of guis in his site..... One of them is "The wxWidgets" as you said.
I will try to write code by myself to produce the above output - for exercise....
After this I will study your code !!
Topic archived. No new replies allowed.
You are using a version without Ads of this website. Please, consider donating: