title: Getting a file's size in C with lseek?
body: <p>I am trying to get the size of a file in C with the following operations... I am new to C</p>
  
  <p>This is my struct mem at the top of my file:</p>
  
  <pre><code>struct mem {size_t size;
              };
  </code></pre>
  
  <p>Is this the correct set up with local variables/return statements and such?</p>
  
  <pre><code>struct mem* fileSize(char* filename)
  {
      currentPos = lseek(filename, (size_t)0, SEEK_CUR);
      size = lseek(filename, (size_t)0, SEEK_END);
      lseek(filename, currentPos, SEEK_SET);   // seek back to the beginning of file
      return size;
  }
  </code></pre>