title: ofstream- Writing an element into a file - C++
body: <p>I want to write numbers into a file .dat in C++. I create a function, it uses ofstream. It's correct?</p>
  
  <pre><code>void writeValue(char* file, int value){
  ofstream f;
  f.open(file);
  if (f.good()){
      f&lt;&lt;value;
  }
  f.close(); 
  }
  </code></pre>
  
  <p>Thanks.</p>