title: c++ program for reading csv writing into array; then manipulating and printing into text file (already written in matlab)
body: <p>was wondering if someone could give me a hand im trying to build a program that reads in a big data block of floats with unknown size from a csv file. I already wrote this in MATLAB but want to compile and distribute this so moving to c++.</p>
  
  <p>Im just learning and trying to read in this to start</p>
  
  <p>7,5,1989<br>
  2,4,2312</p>
  
  <p>from a text file.</p>
  
  <p>code so far.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  #include &lt;stdlib.h&gt;
  
  const int ROWS = 2;
  const int COLS = 3;
  const int BUFFSIZE = 80;
  
  int main() {
    int array[ROWS][COLS];
    char buff[BUFFSIZE];
    std::ifstream file( "textread.csv" );
    std::string line; 
    int col = 0;
    int row = 0;
    while( std::getline( file, line ) )
    {
      std::istringstream iss( line );
      std::string result;
      while( std::getline( iss, result, ',' ) )
        {
          array[row][col] = atoi( result.c_str() );
          std::cout &lt;&lt; result &lt;&lt; std::endl;
          std::cout &lt;&lt; "column " &lt;&lt; col &lt;&lt; std::endl;
          std::cout &lt;&lt; "row " &lt;&lt; row &lt;&lt; std::endl;
          col = col+1;
        }
      row = row+1;
      col = 0;
    }
    return 0;
  }
  </code></pre>
  
  <p>My matlab code i use is >></p>
  
  <pre><code>fid = fopen(twoDM,'r');
  
  s = textscan(fid,'%s','Delimiter','\n');
  s = s{1};
  s_e3t = s(strncmp('E3T',s,3));
  s_e4q = s(strncmp('E4Q',s,3));
  s_nd = s(strncmp('ND',s,2));
  
  [~,cell_num_t,node1_t,node2_t,node3_t,mat] = strread([s_e3t{:}],'%s %u %u %u %u %u');
  node4_t = node1_t;
  e3t = [node1_t,node2_t,node3_t,node4_t];
  [~,cell_num_q,node1_q,node2_q,node3_q,node_4_q,~] = strread([s_e4q{:}],'%s %u %u %u %u %u %u');
  e4q = [node1_q,node2_q,node3_q,node_4_q];
  [~,~,node_X,node_Y,~] = strread([s_nd{:}],'%s %u %f %f %f');
  
  cell_id = [cell_num_t;cell_num_q];
  [~,i] = sort(cell_id,1,'ascend');
  
  cell_node = [e3t;e4q];
  cell_node = cell_node(i,:);
  </code></pre>
  
  <p>Thanks to totrace for fixing the initial compile error i had on my c++ code but im looking for continued tips help, and If someone could give me a hand that would be awesome. </p>
  
  <p>Props, 
  Alex Byasse</p>