c 程序设计语言 第二版 练习题 5-1

来源:互联网 发布:电子书什么软件好 编辑:程序博客网 时间:2024/05/20 23:44
int getint(int *pn) {if (pn == NULL)return -1;int c, sign;while (isspace(c=getchar()));if (!isdigit(c) && c != EOF && c != '+' && c != '-'){ungetc(c, stdin);return 0;}sign = (c == '-') ? -1 : 1;if (c == '-' || c == '+') {c = getchar();if (!isdigit(c)) {ungetc(c, stdin);return 0;}}for (*pn = 0;isdigit(c);c = getchar()) {*pn = 10 * *pn + (c - '0');}*pn *= sign;if (c != EOF)ungetc(c, stdin);return c;}


0 0