mirror of
https://github.com/krislamo/knrc.git
synced 2024-11-10 00:30:35 +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 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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user