⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 char_int.c

📁 C和指针非常好的一本书.里面的有许多代码可以借鉴.
💻 C
字号:
/*
** Convert a series of digits from the standard input to an integer.
*/

#include <stdio.h>
#include <ctype.h>

int
read_int()
{
	int	value;
	int	ch;

	value = 0;

	/*
	** Convert digits from the standard input; stop when we get a
	** character that is not a digit.
	*/
	while( ( ch = getchar() ) != EOF && isdigit( ch ) ){
		value *= 10;
		value += ch - '0';
	}

	/*
	** Push back the nondigit so we don't lose it.
	*/
	ungetc( ch, stdin );
	return value;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -