C - fscanf
File Operations in Tamil
Learn C - C tutorial - C fscanf - C examples - C programs
C - fscanf() - Definition and Usage
- In C – Programming, the fscanf function is used to read formatted input from a stream.
C Syntax
Sample - C Code
C Code - Explanation :
- In this statement we create the character array and the variable name as “str”.
- Here in this statement we create a file pointer “pFile”. Here in this statement we open the text file using “fopen” function in writing mode.
- In this statement we write the content in the text file using fprintf function.
- In this statement we use the rewind function used to find the position of the string.
- In this statement we read the input string using fscanf function.
- After the file manipulation the file will be closed using fclose function.
- Here in this printf statement we print the text file as string.
Sample Output - Programming Examples
- Here in this output the written statement “WelcomeToWikitechy” in the sample.txt file using fprintf function as shown here.
- Here in this output, the statement (“WelcomeToWikitechy”) which has been read in the sample.txt file using fscanf function as shown here.
Example
Output
Learn C - C tutorial - C fscanf - C examples - C programs