Dotcpp  >  编程教程  >  stdio.h头文件  >  C语言fgetchar()函数:从标准输入流中读取字符

C语言fgetchar()函数:从标准输入流中读取字符

点击打开在线编译器,边学边练

函数名: fgetchar

头文件:<stdio.h>

函数原型: int fgetchar(void);

功 能: 从标准输入流中读取字符

参 数: 没有参数 

返回值: 成功  输入流中的下一个字符,它已被转换成为无符号扩展的整型值

              失败  遇到出错或文件结束时返回EOF


程序例: 从控制台中读取字符,并输出

#include<stdio.h>

int main(void){

   char ch;

   printf("Enter a character followed by\n");

   ch = fgetchar();  //从控制台读取字符

   printf("The character read is: '%c'\n",ch); //输出读取的字符

   return 0;

}

 

运行结果

Enter a character followed by
b
The character read is: 'b'



本文固定URL:https://www.dotcpp.com/course/504

C语言函数库
assert.h头文件
ctype.h头文件
float.h头文件
io.h头文件
math.h头文件
mem.h头文件
setjmp.h头文件
stdio.h头文件
stdlib.h头文件
sigal.h头文件
string.h头文件
time.h头文件
Dotcpp在线编译      (登录可减少运行等待时间)