title: How to get the file length in C on Linux?
body: <p>I'm looking for the equivalent of Microsoft's <a href="https://msdn.microsoft.com/en-us/library/dfbc2kec.aspx" rel="nofollow noreferrer">_filelength</a> in Linux. I tried this, but it's incorrect.</p>
  
  <pre><code>long _filelength(char *f)
  {
      struct stat st;
      stat(f, &amp;st);
      return st.st_size;
  }
  
  if((hfile = fopen("data.arp","rb"))!=NULL)
      fsize = _filelength(fileno(hfile));
  </code></pre>
  
  <p>How do I get the file length in C on Linux?</p>