title: Deleting Particular repeated field data from Google protocol buffer
body: <p>.proto file structure   </p>
  
  <p>message repetedMSG
      {
        required string data = 1;
      }</p>
  
  <pre><code>message mainMSG
  {
    required repetedMSG_id = 1;
    repeated repetedMSG rptMSG = 2;
  }
  </code></pre>
  
  <p>I have one mainMSG and in it too many (suppose 10) repetedMSG are present.
  Now i want to delete any particular repetedMSG (suppose 5th repetedMSG )from mainMSG. For this i tried 3 ways but none of them worked.</p>
  
  <pre><code>for (int j = 0; j&lt;mainMSG-&gt;repetedMSG_size(); j++){
                      repetedMSG reptMsg = mainMsg-&gt;mutable_repetedMSG(j);
                      if (QString::fromStdString(reptMsg-&gt;data).compare("deleteMe") == 0){
              *First tried way:-*  reptMsg-&gt;Clear();
              *Second tried Way:-* delete reptMsg;
              *Third tried way:-*  reptMsg-&gt;clear_formula_name();
                          break;
                      }
                  }
  </code></pre>
  
  <p>I get run-time error when i serialize the mainMSG for writing to a file i.e. when execute this line </p>
  
  <p>mainMSG.SerializeToOstream (std::fstream output("C:/A/test1", std::ios::out | std::ios::trunc | std::ios::binary))  <em>here i get run-time error</em></p>