title: How to count number of bytes in a file using C?
body: <p>How to count the number of bytes for a file using C?</p>
  
  <p>Suppose the file below contains some code (data) in it. How does the word count (wc) program count the exact number of bytes for the specified file?</p>
  
  <p>So for example if we have the following file:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main(void) {
      printf("helloworld!");
  }
  </code></pre>
  
  <p>I would like to know how to create a program that can count the number of bytes in that file.</p>
  
  <p>The number of bytes for this file is 64 using Linux word count (wc) </p>
  
  <pre><code>cat helloworld.cpp | wc -c
  64
  </code></pre>