title: C++ Can't write file with peek ; using fstream
body: <p>I create in C++ a function that write in file, by using stream. I want that file was overwrite when i call this code. When i add a fstream.peak, to know the next char, nothing was written in my text file. If they return -1, I want they write at X position in my text file. Here's my code (note that I begin in C++..) Thanks for the future help! :)</p>
  
  <pre><code>fstream myFStream = myFStream.open("./myFile.txt,  ios::in |ios::out | ios::trunc | ios::binary);
  int positionFile = 2;
  myFStream.seekp(positionFile, ios::beg);
  char textToWrite[10] = "";
  textToWrite = "mytext";
  
  **// [don't write when I add this IF]
  if (myFStream.peek() &gt; 0) 
      { positionFile += 15; }**
  
   myFStream.write(textToWrite, 6);
   myFStream.close();
  </code></pre>