title: Reading numbers from file c++
body: <p>I want to read numbers from text file.
  The file contains following numbers.</p>
  
  <p><code>3 5 7 9 20 25 30 40 55 56 57 60 62
  1 4 7 11 14 25 44 47 55 57 100
  -5 100 1000 1005
  -12 1000 1001
  </code></p>
  
  <p>Space separates numbers.
  I had to make some code to read this but the problem is that reading the numbers at the end of line are not correct and I don't know how to read them properly(Problem with CRLF chars);
  Can someone help me with this?
  Here is my code.</p>
  
  <p>Header
  base.h</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string.h&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  class L
  {
      public:
      int value;
  };
  
  class t
  {
  public:
      L *line;
      t(){
          line = new L[10000];
      }
  };
  
  class baza
  {
  public:
      ifstream in;
      ofstream out;
      string lines;
      char word1[1] ;
      int wordint;
      char tab[255];
      int *tab2;
  
      int x;
      int y;
      int z;
      int a;
      int b;
      int c;
      int ile;
  
      int multiplier;
      bool negative ;
      int negative;
      t *table;
  
      base();
  };
  </code></pre>
  
  <p>Here are base.cpp</p>
  
  <pre><code>#include "base.h"
  
  base::base()
  {
      wordint=0;
      a=2000;
      b=0;
      tab2 =new int [a];
      x=0;
      y=0;
      z=0;
  
      for(int i=0;i&lt;a;i++)
      {
          tab2[i]=0;
  
      }
      multiplier=1;
      negative =false;
      negative1=-1;
      lines="0";
      ile=0;
      in.open("in.txt");   //open file
  
      do   
      {
          getline(in,lines);
          if(lines!="0")      //how many lines is in the file
          {
              ile++;
          }
      } while(in.eof()!=true);
      in.close();
      tablica =new t[ile];
      tab5 = new int[ile];
      in.open("in.txt");
  
      for(int i=0;i&lt;ile;i++)
      {
          do
          {
              in.get(word1[0]);
              if(word1[0]==45)   // check if sign is negative
              {
                  word1[0]=0;
                  negative=true;
                  in.get(word1[0]);
              }
              if(word1[0]!= 10)  //check if  not LF
              {
                  if(word1[0]!=' ')  //check if not space
                  {
                      tab[x]= word1[0];
                      x++;
                  }
              }
              if(word1[0]==' ')  //if space then convert from char to int 
              {
                  y=x-1;
                  do {
                      word1[0]=tab[y];
                      wordint=atoi(word1);
                      wordint=wordint*multiplier;
                      tab2[z]=tab2[z]+wordint;
                      y--;
                      multiplier=multiplier*10;
                  } while(y&gt;=0);
                  x=0;
                  multiplier=1;
                  if(negative==true)  //check if negative
                  {
                      tab2[z]=tab2[z]*negative1;
                      negative=false;
                  }
                  z++;
                  c=z;
                  tab5[i]=c;
              }
              /**if(word1[0]== '10')  //its not work but same as above only check if LF
              {
                  y=x-1;
                  do{
                      word1[0]=tab[y];
                      wordint=atoi(word1);
                      wordint=wordint*multiplier;
                      cout&lt;&lt;"dupa";
                      tab2[z]=tab2[z]+wordint;
                      y--;
                      multiplier=multiplier*10;
                  } while(y&gt;=0);
                  x=0;
                  multiplier=1;
                  if(negative==true)  //check if negative
                  {
                      tab2[z]=tab2[z]*negative1;
                      negative=false;
                  }
                  z++;
                  c=z;
                  tab5[i]=c;
              }*/
  
          } while(word1[0]!=10);
          for(int j=0;j&lt;z;j++)      //write to table
          {
              table[i].line[j].value=tab2[j];
              cout&lt;&lt; table[i].line[j].value&lt;&lt;endl;
              tab2[j]=0;
          }
          z=0;
      }
  }
  </code></pre>