 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you the use of fseq and ftel functions in file handling in C programming. 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. So now in this program, I will be demonstrating the use of fseq and ftel functions. First of all, I have included two header files stdio.h and stdlib.h. Now I am going to define main function. Inside main function, I have declared a file pointer that is fp. Now I am going to open a file that is demo.txt and I am going to open it in read mode. After opening the file, I have to check whether it is opened successfully or not. So for that purpose, I have implemented this if condition which is checking whether the file pointer is equal to null or not. So if it is equal to null, then this message error cannot open file will be displayed on output screen and with the help of exit program will be terminated. Otherwise the statements which are available after this if statement will be executed and I am going to read this demo.txt and this demo.txt must be available in this computer and the path will be ctcbin because this source code is stored in test.c and that source code is available in bin folder. So I am opening bin folder. Here you can see demo.txt file which is containing my name Sanjay Gupta. So here total 11 letters are available. So I will be using this demo.txt for demonstration purpose. So I am declaring an integer variable that is n. So first I am calling ftel. So ftel tells the current position of the file pointer. So just after opening the file, I am going to print the position of file pointer with the help of this n. So I am just calling ftel. I am passing fp that is file pointer and the current position of file pointer will be stored inside this n variable and that will be printed on output screen with the help of this printer. So first I am going to execute this code so that you can understand the output. So you can see the position of file pointer equals to 0. So as we open the file pointer, the current position of file pointer is always beginning of the file that is 0 position. If you are using R mode, now I am going to use fseq. So fseq function is you can see here declaration of fseq that is file pointer offset and origin. So file pointer means in which file pointer you want to move the file pointer. Then offset means how much characters or letters you want to skip and origin means beginning. That is c underscore set, c underscore current and c underscore end. That from which point you want to skip the letters. So c underscore set means beginning of file, cur means current position of the file and end means end position of the file. So I am using c underscore set that is beginning of file. So fseq will be skipping six letters from the beginning of file. So again I am going to call ftel so that I can find out the current position of the file. So first it will be displaying 0. Then after fseq, six positions will be skipped. So again I will be finding out the current position of the file through this ftel. That will be stored inside this end variable and that will be displayed on output screen. So again I am going to execute this code. So you can see the output. First it is showing the position of file pointer is zero. Then it is showing the position of file pointer as six. So initially the file pointer is at zero location because it is not pointing to any character. When I have skipped six letters so its current position is just after the six letter. So it is showing six as output. So I hope you have understood how we can find out the current position of the file pointer with the help of ftel. I have also demonstrated you this with the help of fseq. So fseq is shifting the position of file pointer and ftel is just telling you the current position of the file pointer. I am going to move and position of the file. So for that purpose I am using fp, five, seek underscore cur. So current position is six. I want to move to the end of file. So I am passing five here because total number of letters are 11. Now again I am calling ftel and then printf. So now three file positions will be displayed beginning, then real position and then ending position. So again I am going to execute the code. You can see the output. First it is showing zero position that is beginning. Then it is showing six that is the mid position and then it is showing the end position that is 11. So this way I have demonstrated you the use of ftel and fseq function. fseq is used to shift the file pointer from beginning to middle, from middle to end. So for that purpose you can use origins that are seek underscore set, seek underscore current and seek underscore end. And ftel function tells the current position of the file pointer. So these functions are important. You can use these functions to move from one position to another position from file and you can also find out the current position of the file. 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 here. Thank you for watching this video.