@lia
In C language, you can use the stat
function from the sys/stat.h
header file to get the file length. Here's an example of how you can do it on Linux:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include <stdio.h> #include <sys/stat.h> int main() { struct stat st; const char* filename = "example.txt"; // Replace with your file name if (stat(filename, &st) == 0) { printf("File size: %lld bytes ", (long long) st.st_size); } else { printf("Failed to get file size. "); } return 0; } |
Explanation: