title: User input to matrix in C++
body: <p>I have trouble to read in an input from user and convert them into matrix for calculation. For example, with the <code>input = {1 2 3 / 4 5 6}</code>, the program should read in the matrix in the form of </p>
  
  <pre><code>1 2 3 
  4 5 6
  </code></pre>
  
  <p>which have 3 cols and 2 rows. What i got so far which does not seem to work:</p>
  
  <pre><code>input.replace(input.begin(), input.end(), '/', ' ');
      stringstream ss(input);
      string token;   
      while (getline(ss, token, ' '))
      {
          for (int i = 0; i &lt; row; i++)
          {
              for (int j = 0; j &lt; col; j++)
              {
                  int tok = atoi(token.c_str());
                  (*matrix).setElement(i, j, tok);                
              }
          }
      }
  </code></pre>
  
  <p>So what I'm trying to do is to break the input into token and store them into the matrix using the setElement function which take the number of row, column and the variable that user want to store. What wrong with this code is that the variable of <code>tok</code> doesnt seem to change and keep stuck in <code>0</code>. Assuming that row and col are knows.</p>
  
  <p>Thanks so much for any help.</p>