Cubbi wrote:
Note that streams can be copied by simply out << in.rdbuf(); |
thanks man, this is a great advice, i'll make sure to use it in the future.
jlb wrote:
With the current standard (C++11) it appears that if only eof() is set the seek will reset the eof flag and preform the seek. |
i think i'm somewhat outdated, i'm writing my project in the 98 standard.
anyway, after i read your comments i started a research and found something:
i mis-spotted the true error in my project, i can now see the true error:
actually my program processed a file (
1.txt mentioned above) and saved the process result in a temporary file then called
Copy() to move the contents from
Temp to
1.txt, the put-pointer in
Temp is not in the beginning of the file, maybe this made the get operations to malfunction, that's unlikely the problem however.
another cause is, the processing of
1.txt sat the
eofbit, so the seek operation
out.seekp(0,ios::beg);
failed to continue, that's the true cause in my opinion.
i added
out.clear();
to the
Copy() function and that solved the problem.
my deep thanks to all of you, your contributions were a great help.