title: Assign values to a 2D vector from a file on c++
body: <p>Im trying to assign values to a 2d vector, this is the way that i defined the vector, and also its important to say that rows and columns, are ints previously defined</p>
  
  <pre><code>vector &lt; vector &lt;int&gt;&gt; vec(rows , vector &lt;int&gt; (columns,0));
  </code></pre>
  
  <p>i want to assign to this vector, each char of a pbm file, this file only have '1' and '0', so this is the way im reading it</p>
  
  <pre><code>char i;
  FILE* fp;
  fp = fopen("file.pbm", "r");
  </code></pre>
  
  <p>on this way im assigning values to the vector</p>
  
  <pre><code>for (int h=0; h&lt;rows; h++){
      for (int j=0; j&lt;columns; j++){ 
          while((i=fgetc(fp))!=EOF){
              vec[h][j] = i;
          }
      } 
  }
  </code></pre>
  
  <p>but when i try to print all the vector content, this one, only have '0'</p>
  
  <pre><code>for (int h=0; h&lt;rows; h++){
          for (int j=0; j&lt;columns; j++) 
              cout &lt;&lt; vec[h][j];
      cout &lt;&lt;endl; 
  }
  
  fclose(fp);
  </code></pre>
  
  <p>If anyone could tell me where im failing when i make this assignment, thanks!</p>
  
  <pre><code>vec[h][j] = i;
  </code></pre>