title: Reading a huge text
body: <p>I am trying to read a file like I use option <code>more</code> in Linux. I am just trying to make almost the same realization of <code>more</code>. 
  My problem is when I read file in order like:</p>
  
  <pre><code>aaaaaaaaaaaaaaaaaaaa
  
  bbbbbbbbbbbbbbbbbbbbb
  .....................
  ccccccccccccccccccccc
  </code></pre>
  
  <p>For, example: I have 100 strings in <code>txt.file</code>, in order which I showed you. So every string does not exceed the horizontal size of the console and goes after <code>ENTER</code>.</p>
  
  <p>The program works excellent. I mean, if my information of a <code>txt.file</code> does not show fully, I just press <code>SPACE</code> and see another screen of my information from a file. </p>
  
  <p>But if I put a huge text with long strings, It just read a file fully and shows me the end of the file. 
  What do I do wrong with this? Might I not considered the horizontal size of a console? But I think, Linux thinks for me in this case.. Can you help me with this? </p>
  
  <p>My arguments are:<code>./more 0 1.txt</code></p>
  
  <p><code>./more</code> - make file, <code>0</code>- I beging on this string, <code>1.txt</code> -file name.</p>
  
  <p>My code :</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;sys/ioctl.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;termios.h&gt;
  
  
  int getch();
  void printRecord(int&amp; numStr,struct winsize w, std::vector&lt;std::string&gt;&amp; lines);
  
  int main(int argc, char *argv[]) {
      struct winsize w;
      char ch;
      ioctl(STDOUT_FILENO, TIOCGWINSZ, &amp;w);
      std::ifstream readRecord;
      std::vector&lt;std::string&gt; lines;
  
          std::string str;
          readRecord.open(argv[2]);
          int numStr= atoi(argv[1]);
  
          while (!readRecord.eof())
          {
              getline(readRecord, str);
              str.size();
              lines.push_back(str);
          }
              printRecord(numStr,w, lines);
  
           ch=getch();
  
             while(ch!='q'){
              if (ch==32)
              {
                numStr--;
                  printRecord(numStr,w,lines);  
              }
  
              if (numStr&gt;=lines.size()){
                  break;}
             ch=getch();
              }
  
      return 0;
  }
  
  void printRecord(int&amp; numStr,struct winsize w,std::vector&lt;std::string&gt;&amp; lines)
  {
  
      for (int i = numStr; i  &lt;  numStr + w.winsize::ws_row-1; i++)
      {
  
          if (i&gt;=lines.size())
              break;
          else
              std::cout &lt;&lt; lines[i] &lt;&lt; std::endl;
  
      }
  
      numStr += w.winsize::ws_row;
  }
  
  int getch()
  {
      int ch;
  
      struct termios oldt, newt;
      tcgetattr( STDIN_FILENO, &amp;oldt );
      newt = oldt;
      newt.c_lflag &amp;= ~( ICANON | ECHO );
      tcsetattr( STDIN_FILENO, TCSANOW, &amp;newt );
      ch = getchar();
      tcsetattr( STDIN_FILENO, TCSANOW, &amp;oldt );
  
      return ch;
  }
  </code></pre>