Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use the fgetc function in C language

Shulou Source: shulou.com Published: 2022-05-31 10:56:10 10月14日 Update

This article Xiaobian for you to introduce in detail "how to use the fgetc function in the c language", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to use the fgetc function in the c language" can help you solve your doubts.

1. The character returned by the fgetc function is actually the character pointed to by the position pointer in the file stream.

When the fgetc function reads an error, it returns EOF and sets the file error flag bit.

2. This function returns the read characters in the form of unsigned char cast to int, and returns EOF if it reaches the end of the file or if a reading error occurs.

Example

# include # include main () {int c; FILE * fp = fopen ("D:\\ test.txt", "r"); if (fp = = NULL) {printf ("Open file failed!\ n"); exit (1);} while ((c = fgetc (fp))! = EOF) printf ("% c", c); fclose (fp) } after reading this, the article "how to use fgetc functions in c language" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.

Tags: Function language character file article content error proper location instance actual actually form idea point pointer new knowledge more end flag Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker NVidia MySQL Linux Shulou Information