练习 1-8 编写一个统计空格、制表符与换行符个数的程序。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/navicheung/article/details/83573270

C语言程序设计(第二版) 练习1-8 个人设计

练习 1-8 编写一个统计空格、制表符与换行符个数的程序。

代码块:

#include <stdio.h>
#include <stdlib.h>
int main()
{
	int space=0, tab=0, line=0, c;
	while ((c=getchar())!=EOF){
		if (c==' ')
			++space;
		if (c=='\t')
			++tab;
		if (c=='\n')
			++line;
	}
	printf("space=%d, tab=%d, line=%d\n", space, tab, line);
	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/navicheung/article/details/83573270
1-8