title: Delete line (textBox) from file C++
body: <p>I enter text into textBox, and when button is clicked how can I delete line(entered in textBox) from file?</p>
  
  <p>My deleting method code:</p>
  
  <pre><code>public: System::Void deleteOneRejuser() 
      {
          string fileName = "mainBase/main.txt";
          fstream file;
  
          file.open(fileName, ios::in);
  
          char buf[255];
          string text;
  
          //read all lines in file and write in 'buf'
          while(file.getline(buf,255,'\n'));
  
          //converting
          text = (const char*) buf;
  
          //convert textBox text in string    
          System::String^ myString = textBox2-&gt;Text;
          string str = msclr::interop::marshal_as&lt; string &gt;( myString);
  
          int pos = text.find(str);
  
          if ( pos == (int) string::npos )
              this-&gt;label2-&gt;Text = "Bad line, not found";
  
          text.erase( pos, str.size() );
  
          file.close();
  
          file.open(fileName, ios::out);
          file &lt;&lt; text;
          file.close();
      }
  </code></pre>
  
  <p>VS 2010
  Windows Forms</p>