title: ofstream::write fails in the middle when writing large binary files
body: <p>During runtime my program creates and writes two large binary files simutaneously to the disk. File A is about 240GB, file B is about 480GB. The two files are maintained by two <code>ofstream</code> objects, and the write opertations are performed with the member funcion <code>write</code> in a loop.</p>
  
  <p>Now the problem is: The write file operation fails everytime the whole write file procedure reaches 63~64%. The first time it failed on file A, and the second time it failed on file B.</p>
  
  <p>During the program runs these days, the power supply of my building happens to be under upgrade. By a strange coincidence, every time the program failed, the electrician happened to be cutting and resuming the power supply of the central air-conditioner and some offices. Therefore, I really wonder whether the write file failures were caused by unstable power supply.</p>
  
  <p>I'm sure that the failure is not caused by file size limit, because I've tried to write a single 700GB file using the same method without any problem.</p>
  
  <p>Is there any way to find out the detailed reason? I feel that the flags (<code>badbit</code>, <code>eofbit</code> and <code>failbit</code>) of <code>ofstream</code> don't provide too much information. Now I'm trying to use <code>errno</code> and <code>strerror</code> to get the detailed error message. However, I see that a possible value of <code>errno</code> is <code>EIO</code>, which measn "I/O error", which again provides no useful information.</p>
  
  <p>Is there anyone who encountered this situation before?</p>
  
  <p>By the way, the program runs without error when the sizes of file A and file B are small.</p>
  
  <p>PS: This time the program fails at 55%, and the errno value is EINVAL: Invalid argument. Very strange.</p>