Display size of the file - C

Display file size

Snippet Code


  
Rate this page :
  [ 0 votes]

#include <io.h> #include <fcntl.h> #include <sysstat.h> int main() { int fp; long file_size; if ((fp = open(<q>f:abc.txt</q>, O_RDONLY)) == -1) printf(<q>Error opening the file n</q>); else { file_size = filelength(file_handle); printf(<q>The file size in bytes is %ldn</q>, file_size); close(fp); } return 0; } Output: ====== The file size in bytes is: 2048

Tags


Ask Questions

Ask Question