 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you the use of FEOF function available in file handling in C. 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 solution of this problem. So first I have included a header file stdio.h, another header file stdlib.h. Now I am going to define main function. Inside main function, I am declaring a file pointer that is fp. Then I have declared a character variable that is ch. Now I am opening a file whose name is contain.txt and I am opening it in read mode. And the address of this file will be stored inside fp. Now I have to check whether this file is opened successfully or not. So this if statement will be checking fp is equal to null or not. So if it is equal to null, then I can print an error message that is cannot open file. And I can call exit function so that execution of the program can be terminated. After this if condition, I have to implement the use of fpuf. So for that purpose, I am going to implement while loop. Now inside this while condition, I am calling fpuf and I am passing fp inside this fpuf function. So fpuf function checks the location of file pointer. fpuf returns nonzero if file pointer is on end of file, otherwise 0. So you have to focus on this comment. fpuf is a predefined function which checks location of file pointer and it returns nonzero if file pointer is on end of file, otherwise it returns 0. So now suppose file pointer is in middle of file. It means there are some contents available in a file. So fpuf will return 0 and 0 means false. So this loop will not repeat and I want to repeat this loop if file pointer is on some content of the file. So I am applying not here. So not will convert false into true so that this loop will repeat. And if fpuf checks file pointer location and if file pointer is on EOF, then it will return nonzero. So nonzero is considered as true. But if file pointer is on end of file, then I have to terminate this loop. So nonzero will be converted into 0 if I am writing this not operator. So whenever you checks file pointer location with the help of this fpuf function, then you have to use this not operator so that loop can be repeated properly. Now inside this loop, I can read values available in file with the help of fgetc. So the received character will be stored inside ch and I can print that character on output screen with the help of printer. So this way I have implemented this loop with the help of fpuf. So fpuf will check the location of file pointer and accordingly this loop will be repeated after termination of this loop. I can close this file and then return 0. So this way I have implemented complete code in front of you. Now I am saving this file in CTC bin and name of file is test.c. So it is already saved at this location. Now I am opening this location CTC bin and here you can see contain.txt is already available. And you can see it is contained. It is having the contain. My name is Sanjay Gupta. So contain.txt is containing this text. So now I am going to execute the code which will read this contain.txt. Now after execution you can see the result. The contain which were available in contain.txt is showing on output screen. That is my name is Sanjay Gupta. So this is done with the help of two functions. One is fpuf and another one is fgetc. Fpuf is checking whether file pointer is on end of file or not. And fgetc is reading a particular character available in a file. So this way you can control the loop with the help of fpuf so that you can check whether the file pointer is on end of file or not. So I hope you have understood the use of fpuf in place of this loop. You can use another loop that is y1 and here you can use fgetcfp. Now you have to check explicitly whether we are on end of file or not. So this way you can check it. If ch is containing end of file then loop will be terminated. Otherwise you can print the character on output screen. So you can use this loop also in place of this while loop. But in this while loop you don't have to check whether file pointer is on uf or not explicitly because it is done with the help of fpuf. So you have both the options. You can use any one whichever is required. Now I am making this statement as comment and I am again executing this code so that you can see whether it is working properly or not. You can see the output. My name is Sanjay Gupta is printed again on output screen with the help of this loop which I have implemented right now. So there are two ways to read content of file. You can use feof function to control the location of file pointer or you can explicitly check the location of file pointer with the help of this if condition which is implemented in front of you. I hope you have understood whatever I have explained in this video. This is all about feof function used in file handling in C programming. 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.