title: Is there any more efficent way to read files in c++?
body: <p>I am a newbie in C++ and I am trying to read integers from a large txt file.</p>
  <p>But the speed is a little bit low and it takes about twenty seconds.
  The file is about 20MB.
  So I want to ask that is there any more efficient way to read integers?
  Here is my full code.</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include&lt;fstream&gt;
  
  int main()
  {
  
      std::ifstream fp(&quot;largeUF.txt&quot;);//The file need to read
      if (!fp)
          std::cerr &lt;&lt; &quot;fail to open!&quot; &lt;&lt; std::endl;
      
      
      int num;
      
      
      while (fp &gt;&gt; num)
      {
          //I just want to read all integers into the  variable
      }
  }
  </code></pre>
  <p>I did this in visual studio 2019 and run the code.
  The data can be accessed by the following link.
  <a href="https://www.dropbox.com/s/5c56rg92ku72ecf/largeUF.txt?dl=0" rel="nofollow noreferrer">The data</a></p>