title: Make 2D Array by Splitting a text with a delimiter C++
body: <p>Well I have that code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main()
  {
  std::string s = "0,0,0,1,1,1,0,0,1";
  std::string delimiter = ",";
  
  int x = 0;
  std::string mapa[9];
  
  size_t pos = 0;
  std::string token;
  while ((pos = s.find(delimiter)) != std::string::npos) {
      token = s.substr(0, pos);
      std::cout &lt;&lt; token &lt;&lt; std::endl;
      s.erase(0, pos + delimiter.length());
  
      mapa[x] = token;
      x++;
  }
  std::cout &lt;&lt; s &lt;&lt; std::endl;
  cin.get();
  }
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/14265581/parse-split-a-string-in-c-using-string-delimiter-standard-c">Parse (split) a string in C++ using string delimiter (standard C++)</a></p>
  
  <p>I have x array, but I need a second dimension the Y... I get the content from a text file called map.txt:</p>
  
  <pre><code>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  </code></pre>
  
  <p>And I need to split it by commas (for the x) and later by newlines (for y)...</p>
  
  <p>But Idk how to do the Y array... What Can I do?</p>
  
  <p>Thanks!</p>