1 Star 0 Fork 0

赵子豪 / The-C-Programming-Language

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
getint .c 577 Bytes
一键复制 编辑 原始数据 按行查看 历史
赵子豪 提交于 2017-03-14 14:31 . Create getint .c
#include <stdio.h>
int getch(void);
void ungetch(int);
/* getline函数:将输入中的下一个整形数赋值给*pn */
int getint(int *pn)
{
int c, sign;
while (isspace(c = getch())) /* 跳过空白符 */
; /* 新值覆盖旧值 */
if (!isdigit(c) && c != EOF && c != '+' && c != '-') {
ungetch(c); /* 输入的不是一个整数,退回去 */
return 0;
}
sign = (c == '-' ? -1 : 1);
if (c == '+' || c == '-')
c = getch();
for (*pn = 0; isdigit(c); c = getch())
*pn = 10 * *pn + (c - '0');
*pn *= sign;
if (c != EOF)
ungetch(c);
return c;
}
C
1
https://gitee.com/zhao_zihao/The-C-Programming-Language.git
git@gitee.com:zhao_zihao/The-C-Programming-Language.git
zhao_zihao
The-C-Programming-Language
The-C-Programming-Language
The-C-Programming-Language

搜索帮助