 Hello everyone, my name is Nikhil Gadjam working as Assistant Professor in Department of Computer Science and Engineering in Valchand Institute of Technology, Solapur. In today's session we will see accessing file through a different file handling function in C. Now learning outcome of this session is at the end of this session student will be able to access file using different file handling function in C. Now these are different file handling function in C. Basic is writing character into the file. So reading and writing character we have two file handling function that is F gate C and F put C. Next two character is string, string is array of characters. So for reading and writing string from file and to the file we have two functions F gate S and F put S. Apart from character and string we can write a different data types into the file and we can read different data types from the file. So we have F printf and F scanf two functions. For writing and reading user defined data type like structures we have F read and F write function. We will see all these functions in detail now. First function is F gate C. F stands for file, gate stands for read and C stands for character. So F gate C function is used to read a one character from the file. So syntax is F gate C in bracket one argument that is file pointer. Return type of this function is a character which is read from the file. So it returns one character from the file where file pointer is pointing. So important in this is a position of file pointer. So where file pointer is pointing from that position one character is read and that is written. So example, so in void main I have character C as a declared one variable file star Fp, Fp is a file pointer is equal to F open abc.txt comma read mode. So I have opened abc.txt in read mode do. So I have used do while function for reading all the characters from the file. C is equal to F gate C Fp. So one character is read that is stored in C printf % C. So whatever character is read from the file I have printed. So this do while loop will continue till C is not equal to end of file. End of file is a special character used for indicating the end of file. So this program will print all the characters present in the file. Next function is F put C. So F stands for file put stands for writing C stands for character. So this function is used to write one character into the file. Syntax is F put C character comma file pointer. So it accepts two arguments first one is character which is to be written into the file and second one is file pointer. So it will write one character into the file where file pointer is pointing. This is a program for writing a character by character from the string into the file. So character str of 50 is a string containing hello as a string. So file star Fp is equal to F open pqr.txt in w mode. w means in writing mode. So for i equal to 0 i less than str alien. So string length in bracket str it is used for accessing character by character from string str. So F put C in bracket str of comma fp. So it will write one by one character of string str into the file where fp means file pointer is pointing. Now next two character is string. String is array of characters. Now we have a function F get S and F put S for reading a complete string or writing a complete string into the file or from the file. So F stands for file get stands for read as stands for string. So this function is used for reading a one string from the file syntax is F get S in bracket string comma n comma file pointer. So it returns n character from the file where file pointer is pointing. So it will read n characters where file pointer is pointing from that point and stored in string example. So file star Fp is equal to F open abc.txt in r mode. So abc.txt is a file opened in read mode F get S comma 10 comma fp. So this function will read 10 characters from where fp is pointing and that 10 characters will be stored in S. So print f string is equal to percent S comma S. So it will print a string of length 10 characters from where fp is pointing into the file abc.txt. Next function is F put S. So S stands for string put stands for writing F stands for file. So this function is used for writing a one string into the file syntax is F put S string which is to be returned into the file pointer. So it will write a string into the file where file pointer is pointing. Example suppose I want to write hello solapur in file abc.txt. So this is a program given. So function is F put as S comma fp. So it will write S as a string which contains hello solapur in file abc.txt where file pointer is pointing. Now next two functions are F printf and fscanf used for reading and writing other data type than character or a string. Suppose I want to write or read integer or write or read a double value or write or read a float value we can use F printf and fscanf. So syntax is F printf file pointer access specifier and variables. So this is a program suppose I want to write one integer value one string and one float value. So I will write F printf in bracket fp is a file pointer percent d percent s and percent f these are access specifier for integer roll number string name and float value percentage. So F printf in bracket fp percent d percent f percent s and percent f for roll number name and percentage. Next one fscanf is used for reading different data types from the file. Suppose I want to read one integer value one string value and one float value. So I will use function fscanf fp is a file pointer. First I will read percent d for roll number percent s for name and percent f for percentage. I will read these values from the file and store in variables roll number name and percentage. So think and write find out the answer which function is useful in writing a user input a string into the file. So we have three functions using which I can write a string into the file f put c by character by character I can write a string f put s directly we can write string into the file f printf again using access specifier I can write a string into the file. Next function is f write f read and f write these are two functions for reading and writing a structure into the file. So I have declared one structure struct student containing three variables roll number and percentage. So void main I want to write a structure student s into the file. So I will use function f write f write functions accepts four parameters first one is reference to structure next one is size of structure next one is number of occurrences for reading and writing and last one is file pointer. So in this case I have used f write reference of s comma size of s comma one number of occurrences and file pointer is fp. So this will write one structure student s into the file next function is f read use for reading a structure from the file. So I have function f read it against accept four parameters first one is reference of structure next one is size of structure next one is number of occurrences and last one is file pointer. So I have used function f read first one is address of s this is reference of s size of s comma one and comma fp. So this function will read one structure student s from the file and stored in s. So I have printed roll number and percentage after reading. So these are different references I have used for creating this video. Thank you.