/* Include files needed */ # include /* The function */ unsigned long filesizeof(FILE *stream){ long curpos, length; /* Save the current position of the file pointer */ curpos = ftell(stream); /* Go to the end of file */ fseek(stream, 0L, SEEK_END); /* The length is the position of the pointer */ length = ftell(stream); /* Set the pointer to the old position */ fseek(stream, curpos, SEEK_SET); /* Return the length */ return length; }