Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

File Length In Bytes

DZone's Guide to

File Length In Bytes

·
Free Resource

#include 
  
   
#include 
   
    
#include 
    
     

int main(int argc, char *argv[])
{
  struct stat file_status;

  /* parsing the command line */
  if (argc!=2) {
    fprintf(stderr, "Usage: filelen file_name\n");
    exit(1);
  }
  else {
    if (stat(argv[1], &file_status)) {
      fprintf(stderr, "Error occured!\n");
      exit(2);
    }
    else
      printf("%d\n", file_status.st_size);
  }

  return(0);
}

    
   
  
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}