 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can find out size of file with the help of a C program. Before starting, you can note how you can search my YouTube channel. You can type my name Sanjay Gupta in YouTube. My channel will be available there. You can watch various programming related videos here. Now I am going to implement a code in front of you, which will tell you the size of file. So first I am going to include two header files stdiv.h and stdlib.h. Now I am going to define main function. Inside main function, I have declared a file pointer and integer variable n. Now I am going to open a file whose name is demo.txt and I am going to open it in read mode. So this file will be available on the path that is ctcbin because I have saved this source code in a test.c file which is in bin folder. So I am opening bin folder. Here you can see demo.txt is available and it is containing total 11 characters. So the size of file is 11. So I am going to show this size with the help of C program. Now after opening this file, I have to check whether the file is opened successfully or not. So for that purpose, I am implementing this printf and exit will be terminating execution of the program if file pointer is equals to null. So if this condition is false, then remaining statements will be executed. So now after opening file, the current position of the file pointer is zero. That is beginning position of the file. I have to move to the end of file so that I can find out the total size of the file. So for that purpose, I am calling fseq. I am passing three arguments in it. That is first is file pointer. Second one is zero and third is c underscore and so c underscore and is denoting origin. So origin is end of file. From end of file, I have to move to the zero characters. So from end of file, I will be moving to zero location. It means I will be on end of file. So with the help of this fseq, I will be shifted to end of file. So after opening of file, the file pointer will be at beginning, but after execution of this fseq statement, file pointer will be at end of file position. Now I can find out the current position with the help of ftel. So ftel find out current position of file pointer. So file pointer's current position will be found out with the help of this ftel and that value will be stored inside this end variable. Now I can print size of file with the help of this end. So end is containing the current position of file pointer that is end of file. So end will be displaying total size of file or you can say total number of content which are available in the file. Then I can call fclose fp. So this way I have implemented this code in front of you. Now I am going to execute this code. You can see the output size of file is equals to 11. So you can see the program is working properly. The file which is available in build folder is containing only 11 characters. So you can also see this is size of file in terms of bytes. It is requiring 11 bytes to store 11 characters in the file. So this way you can count how many data is available in file or you can count the size of file. So I have used two functions fseq and ftel. fseq shifted file pointer from beginning to end with the help of this c underscore end. And ftel is used to find out current position of the file pointer. So I hope you have understood whatever I have demonstrated you in this video. If you want to watch more programming related videos you can search my name Sanjay Gupta in YouTube. My channel will be available there. You can watch various programming related videos there. Thank you for watching this video.