My friend Catfish2, thanks for replying ...
I understand that ofstreams do not need ios::out.
What other purposes for, we use the ios::trunc ??
If I use
ofstream out("/bla/bla/a1.txt");
it is the same with (it does the same .. I just tried it ...)
ofstream out("/bla/bla/a1.txt", ios::trunc);
So for what purpose we use the ios::trunc ?? You know I searched a lot of ebooks, but no one explains it !!!!
Anyway it is honnorable for me for replying .... What is your opinion for this my friend ?
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.
Edit:
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?
My friend I just show your answer...
Give me a couple of hours to study in these you wrote me (and other things in this subject), and I will call you back !
Friend I didn't try it before for reading or writing the fstream, I just wanted to check what trunc does in this case....
Now I tried the following 2 and both truncate the file:
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 !!