I have the following code
fin.close();
open = inName + ".xxx";
fin.open(open.c_str(),ios::binary);
fin>>noskipws;
while (fin>>_4byte[0])
{
fout<<_4byte[0];
}
I also have fout open in binary mode too.
However, this code was working perfectly, but suddenly after adding a loop before it it stopped outputting all the data, it is missing somewhere around 33~55 bytes.
I tried removing every other fin.open
and fin.close
to keep this one, but I keep on getting the same issue which is the output file is missing some data.
_4byte
is an unsigned char array
.
So I solved it, the issue was that I only had to add fin.close()
after the while loop. I'm not sure why it happened. Can someone explain the reason?
Edit:
Okay that was not the issue.
After this code I had a cin
, it actually stops writing when it reaches the cin if it hadn't done writing yet.