Return the current position in a stream: how to use ftell
#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; }