repo.or.cz
/
C-Programming-Examples.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Added print and reverse stack functions. Still needs improvement,
[C-Programming-Examples.git]
/
word_count.c
blob
0f4b19c306b962ae8ceb58202a5770c5b4039d24
1
#include <stdio.h>
2
3
#define IN 1
4
#define OUT 0
5
6
main
()
7
{
8
int
c
,
nl
,
nw
,
nc
,
state
;
9
10
state
=
OUT
;
11
12
nl
=
nw
=
nc
=
0
;
13
while
((
c
=
getchar
()) !=
EOF
)
14
{
15
++
nc
;
16
if
(
c
==
'
\n
'
)
17
++
nl
;
18
if
(
c
==
' '
||
c
==
'
\n
'
||
c
==
'
\t
'
)
19
state
=
OUT
;
20
else if
(
state
==
OUT
)
21
{
22
state
=
IN
;
23
++
nw
;
24
}
25
}
26
printf
(
"%d %d %d
\n
"
,
nl
,
nw
,
nc
);
27
}