1
0
mirror of https://github.com/krislamo/knrc.git synced 2024-09-19 21:00:35 +00:00

Exercise 1-8. count blanks, tabs, and newlines

This commit is contained in:
Kris Lamoureux 2021-11-09 00:51:39 -05:00
parent 6bf093f44f
commit 93acdbe7e9
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925

View File

@ -2,11 +2,20 @@
int main() int main()
{ {
int c, n1; int c, b, t, n;
n1 = 0; b = 0;
while ((c = getchar ()) != EOF) t = 0;
n = 0;
while ((c = getchar ()) != EOF) {
if (c == ' ')
++b;
if (c == '\t')
++t;
if (c == '\n') if (c == '\n')
++n1; ++n;
printf("%d\n", n1); }
printf("blanks = %d\n", b);
printf("tabs = %d\n", t);
printf("newlines = %d\n", n);
} }