C - The C Answer (2nd Edition) - Exercise 1-8
Posted brucemengbm
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C - The C Answer (2nd Edition) - Exercise 1-8相关的知识,希望对你有一定的参考价值。
/* Write a program to count blanks, tabs, and newlines. */ #include <stdio.h> /* count blanks, tabs, and newlines */ main() { int c, nb, nt, nl; nb = 0; /* number of blanks */ nt = 0; /* number of tabs */ nl = 0; /* number of newlines */ while((c = getchar()) != EOF) { if(c == ‘ ‘) { ++nb; } if(c == ‘\t‘) { ++nt; } if(c == ‘\n‘) { ++nl; } } printf("%d %d %d\n", nb, nt, nl); }
以上是关于C - The C Answer (2nd Edition) - Exercise 1-8的主要内容,如果未能解决你的问题,请参考以下文章
C - The C Answer (2nd Edition) - Exercise 1-6
C - The C Answer (2nd Edition) - Exercise 1-8
Title : Using Information Fragments to Answer the Questions Developers Ask