 अभाई आई मेंनाजम छाराव अआई आई आई अगी आई आई आईआई आई आई आई आई, हो ब वी स्टि audiobook  कछग दब अता एक दर वो औम उपना स्बले है, पर excluded जाराव अई आई आई आई में भिग वो भी अम आई आई, आई माई अई आई आई आई, और प्दे. आ� student.txt and i am going to open it in wb mode so w is for write and b is for binary so whenever you use fwrite and fread functions for reading and writing structure into file you have to use binary mode because fread and fwrite works for binary data only so here after opening the file i have to check whether the file is opened successfully or not so for that purpose i have implemented this f condition which is checking whether the file pointer is containing null or not so if it is containing null then i can print this error message that is cannot open file and then i can call exit function otherwise this f condition will be false and the statements which are available after if will be executed so now i have to read roll number and name from user so for that purpose sorry i am writing this printf and then through scanf i am going to read roll number from user in s dot roll number variable now i have to read name of student so the message enter name will be displayed before reading name i have to call this function fplush which will clear the buffer memory and then through gattus i am going to read name of student so this way i have received roll number and name from user with the help of scanf and gattus function now i can write this structure variable in a single statement into a file so with the help of fwrite function i am going to write this structure variable into file so for that purpose i am going to pass four arguments in fwrite so fwrite is writing structure into file so now you have to understand these four arguments which i have passed in fwrite so first argument is address of structure variable that is s second is denoting size of struct student and third is denoting quantity so s is a single variable that's why i am writing one and fourth is destination that is fp which is pointing to student dot txt so this data will be stored in student dot txt file with the help of file pointer now i can print a message for user data is stored successfully so this message will be displayed on output screen and then f close fp so this way i have implemented first part of this video which is demonstrating the use of fwrite so the data will be stored in file that is student dot txt and data will be stored in binary format and this program is saved in test.c the path of this file is ctc and bin that you can see on title bar of the program ctc and bin so this student dot txt will be available on that path that is ctc bin folder now i am going to execute this program so you can see it is asking for roll number and name so i have entered roll number as 11 and name as sanjay and you can see it is showing the message data is stored successfully in the file so now i have to check whether the data is stored successfully or not so for that purpose i have to open bin folder that is available in ctc so i have opened bin folder now here i have to search student dot txt so i have pressed s so the files which starts from name s are available here and you can see student dot txt is available here and here you can see the data is available but it is in it is in binary format so you can't see roll number but you are able to see a name so whenever you use fwrite function data is stored in binary format so you can't read all the data clearly to read that data clearly you have to use fread function so this is the first part of this video where i have demonstrated you the use of fwrite now i am going to change this code in place of write mode i am going to use read mode and i am going to change these instructions so you can see the code first i have included two header file then student structure then file pointer then structure variable then this time file is opened in read mode and then if condition is checking whether the file is opened successfully or not so now i have to read data from file so for that purpose i am using fread m%s size of struct student then 1 comma fp so this fread statement will read data from file so it reads struct from file so file is denoted with a help of file pointer it will read one record from file and that will be stored inside s variable so file might be containing more than one student records so it will be reading first record that is available in the file now i have to show the received values to the user so for that purpose i am going to write these printf statements then f close so you can read these statements first i have used fread then i have called printf statement wise so first is printing roll number and second is printing name with help of s variable and s is receiving data from file that is fp file pointer and name of file is student.pxt so now while executing this code i don't have to enter anything the data will be received from file and it will be displayed on output screen automatically so now i am going to execute the code you can see on output screen the data which i have stored in the file is displayed on output screen that is roll number 11 and name equals to sanjay so this way with the help of f right i am i am able to write structure into file and with the help of fread function i am able to read the data which is stored in file in form of structure variable and i have displayed that data on output screen so this is all about fread and f right function which are writing and reading structure in file with the help of file handling in c programming 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