目录

int getc(FILE *stream)

描述 (Description)

C库函数int getc(FILE *stream) )从指定的流中获取下一个字符(无符号字符),并前进该流的位置指示符。

声明 (Declaration)

以下是getc()函数的声明。

int getc(FILE *stream)

参数 (Parameters)

  • stream - 这是指向FILE对象的指针,该对象标识要在其上执行操作的流。

返回值 (Return Value)

此函数将读取的字符作为unsigned char cast返回到文件末尾或错误的int或EOF。

例子 (Example)

以下示例显示了getc()函数的用法。

#include<stdio.h>
int main () {
   char c;
   printf("Enter character: ");
   c = getc(stdin);
   printf("Character entered: ");
   putc(c, stdout);
   return(0);
}

让我们编译并运行上面的程序,它将产生以下结果 -

Enter character: a
Character entered: a
↑回到顶部↑
WIKI教程 @2018