Latest web development tutorials

C library functions - getc ()

C standard library - <stdio.h> C standard library - <stdio.h>

description

C library functionsint getc (FILE * stream) obtained from the specified stream stream next character (an unsigned character), and the location identifier move forward.

statement

Here is () statement getc function.

int getc(FILE *stream)

parameter

  • stream - This is a pointer to FILE pointer to an object, the object identifier FILE flow to perform operations on it.

return value

This function as an unsigned char cast to an int return the character read, or if the end of file read error occurs, it returns EOF.

Examples

The following example demonstrates the getc () function is used.

#include<stdio.h>

int main()
{
   char c;

   printf("请输入字符:");
   c = getc(stdin);
   printf("输入的字符:");
   putc(c, stdout);
   
   return(0);
}

Let's compile and run the above program, which will result in the following:

请输入字符:a
输入的字符:a

C standard library - <stdio.h> C standard library - <stdio.h>