title: Writing in .csv file and getting next cell
body: <p>I've found that you need to use <code>,</code> to seperate cells you want to write in, but it somehow doesn't work for me.
  Here is code:</p>
  
  <pre><code>    fileName "example_1.csv"
  
      void World::saveDataToFile(std::string fileName){
      std::ofstream myfile(fileName);
  
  
      if (myfile.is_open())
      {
  
          for (int index = 0; index &lt; dataList.size(); index++){
  
              myfile &lt;&lt; dataList[index].ants &lt;&lt; "," &lt;&lt; dataList[index].beetles &lt;&lt; "," &lt;&lt; dataList[index].empty &lt;&lt; "\n";
          }
          myfile.close();
      }
      else std::cout &lt;&lt; "Unable to open file";
  }
  </code></pre>
  
  <p>It just writes in same cell using commas. I can't find any other solution. </p>
  
  <p>How can I get next cell?</p>
  
  <p><strong><em>EDITED</em></strong></p>
  
  <p>Wrong spreadsheet:</p>
  
  <p><img src="https://i.stack.imgur.com/Cm5A0.png" alt="excel spreadsheet"></p>
  
  <pre><code>//    std::vector&lt; std::vector &lt;Organism* &gt; &gt; world; // wrong vector
        std::vector&lt;Data &gt; dataList; // this is the right one!
  struct Data{
      Data(int a, int b, int e) : ants(a), beetles(b), empty(e){}
      int ants;
      int beetles;
      int empty;
  };
  </code></pre>
  
  <p>Involved functions:</p>
  
  <pre><code>void World::saveData(){
      dataList.push_back(Data(countOrganismType(ANT),countOrganismType(BEETLE),countOrganismType(NONE)));
  }
  int World::countOrganismType(Organism* org){
      int count = 0;  
      for (int x = 0; x &lt; wSizeX; x++){
          for (int y = 0; y &lt; wSizeY; y++){
              if (compare(world[x][y], org)){
                  count++;
              }
          }
      }
      return count;
  }
  </code></pre>