名不副实的getchar()
来源:互联网 发布:三大男高音 知乎 编辑:程序博客网 时间:2024/04/30 03:22
名不副实的getchar()
函数命名通常遵守见名知意的规则,但getchar()貌似就是一个特例,函数名的字面意思即获取一个字符,然而它的返回类型不是char,而是int。
头文件
stdio.h
函数原型
int getchar(void);
函数描述
fgetc() reads the next character from stream and returns it as an unsigned char cast to an int, or EOF on end of file or error. getc() is equivalent to fgetc() except that it may be implemented as a macro which evaluates stream more than once. getchar() is equivalent to getc(stdin).
- 返回值
fgetc(), getc() and getchar() return the character read as an unsigned char cast to an int or EOF on end of file or error.
- 实例
源代码
#include <stdio.h>int main(void){ int a = 0; a = getchar(); printf("a : %d\n", a); return 0;}
运行结果
[root@localhost lwp_workspace]# ./test1a : 49[root@localhost lwp_workspace]#
注意:字符‘1’的ascll即为数字49。
总结
getchar()返回获取字符的ascll或EOF。
0 0
- 名不副实的getchar()
- 名不副实
- 那些名不副实害人不浅的软件
- getchar()的移植问题
- getchar()的一点感受
- 不用回车的getchar()
- getchar隐藏的危险
- getchar()的使用方法
- getchar()遇到的问题
- 关于getchar的理解
- getchar()的详解
- getchar()的错误
- getchar使用的几个问题
- getchar()函数的作用
- scanf、getchar的使用
- getchar()的用法
- getchar()的一点思考
- getchar()函数的理解
- C++ STL中Map的按Key排序和按Value排序
- hdu 5919 Sequence II (可持久化线段树)
- POI读取Excel
- linux系统记录用户操作实现方法
- Swift
- 名不副实的getchar()
- dubbo简单集成spring
- 线程安全
- J2EE系列之Struts2学习笔记(四)---使用javabean方式给类对象赋值
- WPF 选择treeview子节点获取父节点
- ArrayList和LinkedList的区别
- ZOJ 3952 Fibonacci Sequence Chicken Edition 模拟
- web前端性能优化
- SylixOS音频驱动移植