 Hello friends. I am Sanjay Gupta. In this video, I am going to demonstrate you how you can write an integer into a file in C programming. Before starting, you can note how you can search my YouTube channel. You can type my name Sanjay Gupta in YouTube search bar. My channel will be available on first page. You can watch various programming related videos here. Now I am going to implement a code in front of you which will write an integer into a file in C programming. So first of all, I am including a header file that is stdio.h, another file stdlib.h. Now I am going to define main function. Inside main function, I am declaring a variable that is n. Now I am going to declare a file pointer whose name is fp. So this is file pointer which will hold address of a file in which I want to store an integer value. Now I have to open the file in which I want to store the number. So I am typing name of file number.txt and I am going to open it in w mode. w means write mode. So after execution of this f open function, I have to check whether file is open successfully or not. So for that purpose, I am implementing this if condition. If fp is equals to null, it means file is not open successfully. So in that case, I can print the message error cannot open file. So this message will be displayed on output screen and if file is not open successfully, then I can terminate execution of program by calling exit function. This exit function is declared in stdlib.h header file. So if file pointer is containing an address, then this if condition will be false, otherwise it will be true. So after applying this if condition, I am going to implement printf which will display the message enter a number on output screen. Treat that number. I am calling scanf and the entered number will be stored inside this n variable. Now I have to store this n into the file that is number.txt. So here I am calling f printf function. Now I am passing first argument fp then number equals to %d and then n. So this message number equals to %d will be stored inside file and %d will be replaced with the value stored inside n variable. Now on output screen, I am going to display the message number is stored in file successfully. So this message will be displayed on output screen and then return 0. So this way I have implemented the complete code in front of you. This code will be receiving a number from user and that number will be stored in a file that file name is number.txt. So now first we have to check whether this file is available or not because I have used w mode. So if this file is not available it will be created automatically and the location of this file will be c, tc and win. So I have to open c try then tc folder and then win folder. So I am going to open computer then c try. Now I am going to open tc folder. Now I am going to open win folder. So here I have to search whether number.txt is available or not. So I have pressed n. Now the files which are starting from n are available here. So you can see number.txt is not available here. Now I am going to execute this code. So you can see it is asking for a number. I am entering 10. Now you can see the message number is stored in file successfully. So this message number equals to 10 must be present in number.txt file. So again I have to open the win folder. Here you can see this number.txt file is created automatically. It is available here. Now I am going to open it by double clicking on it. You can see it is having number equals to 10 inside this file. So this way I have stored the message in a text file through a c program. And that text file is created automatically because I have used w mode. And the location of that file is c, tc and bin. So I hope you have understood how we can store a particular number into a file with the help of a c program. So this is all about this program which is implemented with the help of file handling in c. 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.