C - fgetc
File Operations in Tamil
Learn C - C tutorial - C fgetc - C examples - C programs
C - fgetc() - Definition and Usage
- In C - Programming, the getc function is used to read the character from the file.
Sample - C Code
C Code - Explanation
- Here in this statement we create a file pointer “fp”.
- Here in this statement we get the character value for the text file using “getc” function where its values are assigned to the variable “ch”.
- In this while loop statement we check whether the document contains any text or not.
- In this statement we write the character in the display window.
- In this we assign the file pointer to the variable “ch”.
- After the completion of file manipulation, the file will be closed using fclose function.
Sample Output - Programming Examples
- Here in this output the statement “WelcomeToWikitechy” in the notepad file (sample.txt) has been shown which is located in the BIN folder of C.
- Here the text content (“WelcomeToWikitechy”) from notepad file (sample.txt) has been shown in the console window.