Complexted exercise 1-8; count and report number of newline, tab, and blank characters in input.
This commit is contained in:
parent
7682f93933
commit
7be84d6b88
1 changed files with 19 additions and 0 deletions
19
KNR C/ex1_8.c
Normal file
19
KNR C/ex1_8.c
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
|
||||||
|
int a = getchar();
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
while (a != EOF){
|
||||||
|
if (a == '\n' || a == '\t' || a == ' ')
|
||||||
|
++counter;
|
||||||
|
|
||||||
|
a = getchar();
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d", counter);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue