title: text file contents to array
body: <p>I have a text file-> info.txt which contains the follow Id,games,amount</p>
  
  <p>info.txt</p>
  
  <pre><code>1,left4dead,50
  2,warcraft3,60
  </code></pre>
  
  <p>I know how to extract the details using vectors with my codes shown below. </p>
  
  <p>stock.h</p>
  
  <pre><code>#ifndef stock_stock_h
  #define stock_stock_h
  #include &lt;iostream&gt;
  
  class  stock  {    
  public: 
    stock() {
       columnOneText = " ";
       columnTwoText  = " ";
  }
  
  stock(std::string columnOneText,
        std::string columnTwoText
  );
  
  std::string getColumnOne();
  std::string getColumnTwo();
  
  void setItemId(std::string columnOneText);
  void setItemDescription(std::string columnTwoText);
  
  private:
    std::string columnOneText, columnTwoText;
  };    
  #endif 
  </code></pre>
  
  <p>main.cpp </p>
  
  <pre><code>#include "stock.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;sstream&gt;
  #include &lt;vector&gt;
  using namespace std;
  stock::stock(string columnOneText,
           string columnTwoText)
  {
     setItemId(columnOneText);
     setItemDescription(columnTwoText);
  };
   string stock::getColumnOne()    {
     return columnOneText; 
   }
  string stock::getColumnTwo()  {
     return columnTwoText;
  }
  void stock::setItemId(string columnOneText)    {
    this-&gt;columnOneText = columnOneText;
  }
  void stock::setItemDescription(std::string columnTwoText) {
    this-&gt;columnTwoText = columnTwoText;
  }
  
  int main(){
    vector&lt;stock&gt; itemDetails;
    string line;
    string columnOneText;
    string columnTwoText;
    ifstream readFile("info.txt");
  
    while(getline(readFile,line))   {
       stringstream iss(line);
       getline(iss, columnOneText,',');
       getline(iss, columnTwoText, ',');
  
      //consturctor
      stock splitedColumns(columnOneText,
                           columnTwoText
                           );
      itemDetails.push_back(splitedColumns);
  }
  readFile.close();
  
  cout &lt;&lt; "this is column One in text file" &lt;&lt; endl;
  for (int i =0; i&lt;itemDetails.size(); i++) {
      cout &lt;&lt; itemDetails[i].getColumnOne()  &lt;&lt; " " &lt;&lt; endl;
  }
  
  cout &lt;&lt; "this is column Two in text file" &lt;&lt; endl;
  for (int i =0; i&lt;itemDetails.size(); i++) {
      cout &lt;&lt; itemDetails[i].getColumnTwo()  &lt;&lt; " " &lt;&lt; endl;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>what I don't really know is how to extract the details using arrays instead of using vectors. </p>
  
  <p>I have tried this but it doesn't seem to work</p>
  
  <pre><code>  string line;
    string columnOneText;
    string columnTwoText;
    string columnOneTextArray[7];
    while(getline(readFile,line))   {
      stringstream iss(line);
      getline(iss, columnOneText,',');
      getline(iss, columnTwoText, ',');
      for(int i=0; i&lt;8; i++) {
         columnOneTextArray[i] = columnOneText;
         cout &lt;&lt; columnOneTextArray[i];
     }  
  }
  </code></pre>
  
  <p>You guys might ask why do I want to do it in arrays instead of using vector,
  I just curious and exploring how it can be done using arrays. </p>