You need to seek to the end of the file and then ask for the position:
fseek(fp, 0L, SEEK_END);
sz = ftell(fp);
You can then seek back, e.g.:
fseek(fp, 0L, SEEK_SET);
or (if seeking to go to the beginning)
rewind(fp);
More Related Contents:
- how to enter a function to a file in c
- How can I get a text file into a string but whith the “\n” in C?
- Reading and analyzing rooms from text file
- Why is “while ( !feof (file) )” always wrong?
- How do you determine the size of a file in C?
- How does free know how much to free?
- How to read the content of a file to a string in C?
- Download file using libcurl in C/C++
- __FILE__ macro shows full path
- what’s the differences between r and rb in fopen
- Why does stat fail using a name from readdir? [duplicate]
- C pointers : pointing to an array of fixed size
- File I/O with streams – best memory buffer size
- Why is “while( !feof(file) )” always wrong?
- How to use EOF to run through a text file in C?
- How do you get a directory listing in C?
- Using fseek with a file pointer that points to stdin
- Getting terminal size in c for windows?
- practical examples use dup or dup2
- fcntl, lockf, which is better to use for file locking?
- Trouble reading a line using fscanf()
- size of array in c
- What exactly is the FILE keyword in C?
- How to buffer stdout in memory and write it from a dedicated thread
- Append to the end of a file in C
- Does fread move the file pointer?
- How can I change the size of an array in C?
- How to read all files in a folder using C
- Why is the size of a function in C always 1 byte?
- How to declare a structure in a header that is to be used by multiple files in c?