1
0
mirror of https://github.com/krislamo/knrc.git synced 2024-09-19 12:50:36 +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 c, n1;
int c, b, t, n;
n1 = 0;
while ((c = getchar ()) != EOF)
b = 0;
t = 0;
n = 0;
while ((c = getchar ()) != EOF) {
if (c == ' ')
++b;
if (c == '\t')
++t;
if (c == '\n')
++n1;
printf("%d\n", n1);
++n;
}
printf("blanks = %d\n", b);
printf("tabs = %d\n", t);
printf("newlines = %d\n", n);
}