The problem is that in the book that I study from is written that if there is no such file as File1 it will be created automatically and fin.good() will be true. But the first time when there is no such file it outputs "Error". When I start the program for a second time everything is ok because the file already exists.
Can you tell me why is this happening?
@huike I tested the code that I have posted [I wrote it here and that's why I have missed <<(I didn't try to compile it)] on another PC and it outputs "Correct". Maybe something is wrong with my PC. I will check the original code that I have written. :)
In my original code first was ifstream fin(...) and then ofstream fout(...)
And it worked.. I didn't expect that this could be the reason..
Maybe I should first create the file and then to try to access it :)