Complexted exercise 1-8; count and report number of newline, tab, and blank characters in input.

This commit is contained in:
Reina Harrington-Affine 2025-08-13 07:15:47 +00:00
parent 7682f93933
commit 7be84d6b88

19
KNR C/ex1_8.c Normal file
View 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;
}