mirror of
https://github.com/krislamo/knrc.git
synced 2025-01-05 19:10:36 +00:00
Exercise 1-8. count blanks, tabs, and newlines
This commit is contained in:
parent
6bf093f44f
commit
93acdbe7e9
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user