repo.or.cz
/
KandRexercises.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
worked on 1-12
[KandRexercises.git]
/
cutblanks.c
blob
337326758ef4f4669b9d53ec946f72d8a9b48987
1
#include <stdio.h>
2
/* exercise 1-9: truncate a string of blanks to 1 blank */
3
4
main
() {
5
int
c
;
6
int
blank
=
0
;
7
while
((
c
=
getchar
()) !=
EOF
) {
8
if
(
c
==
' '
) {
9
blank
=
1
;
10
}
else
{
11
if
(
blank
==
1
) {
12
putchar
(
' '
);
13
blank
=
0
;
14
}
15
putchar
(
c
);
16
}
17
}
18
putchar
(
'
\n
'
);
19
}