In this program, we are going to share C program to find the size of a file using C programming language. If you are a beginner and want to start learning the C programming, then keep your close attention in this tutorial as I am going to share a C program to find the size of a file with the output.
We have designed this program for beginners for learning purpose. Copy below c program and execute it with c compiler to see the output of the program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <stdio.h> void main(int argc, char **argv) { FILE *fp; char ch; int size = 0; fp = fopen(argv[1], "r"); if (fp == NULL) printf("\nFile unable to open "); else printf("\nFile opened "); fseek(fp, 0, 2); size = ftell(fp); printf("Size of given file is: %d\n", size); fclose(fp); } |
Size of given file is: 31744
Liked this tutorial? Do Like & share with your friends.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.