Mega Code Archive

 
Categories / C / File
 

Return the current position in a stream

#include <stdio.h> int main () {   FILE *file;   long size;   file = fopen ("my.txt","rb");      if (file == NULL)        perror ("Error reading my.txt.");   else {     fseek (file, 0, SEEK_END);     size = ftell(file);          fclose (file);     printf ("Size of my.txt is %ld bytes.\n",size);   }   return 0; }