ftell finds the distance between the start location of the file and the current fine pointer location
fseek(f, 0, SEEK_END); // Move the file pointer to the end of the file
size = ftell(f); // return the distance from the beginning to the end of the file
flook(f, 0, SEEK_SET); // Move the file pointer to the beginning of the file
stat returns information about the file in the structure.
#include <sys/stat.h>
struct stat st;
stat(filename, &st);
size = st.st_size;
© 2024 OneMinuteCode. All rights reserved.