title: checking error while writing to a file
body: <p>I have</p>
  
  <pre><code>ofstream myfile;
  myfile.open(filename,ios::out | ios::app);
  if(myfile.good()){ do smtg};
  
  myfile.write(taskToWrite-&gt;buffer,taskToWrite-&gt;length);
  </code></pre>
  
  <p>Is there anyway to check if the write function doesn't work?
  I'm checking before, with good(), but if I have an error while writing , how can I check it?
  I couldn't understand what does the function returns.</p>