mirror of
https://github.com/krislamo/knrc.git
synced 2024-11-10 00:30:35 +00:00
Exercise 1-9. Replace multiple blanks with one
This commit is contained in:
parent
93acdbe7e9
commit
a8ca4de90f
16
07-extra-blanks.c
Normal file
16
07-extra-blanks.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
int l;
|
||||||
|
|
||||||
|
while ((c = getchar()) != EOF) {
|
||||||
|
if (c == ' ' && c == l) {
|
||||||
|
;
|
||||||
|
} else {
|
||||||
|
printf("%c", c);
|
||||||
|
l = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
Makefile
5
Makefile
@ -1,4 +1,4 @@
|
|||||||
all: hello mathvars c2f input count countlines
|
all: hello mathvars c2f input count countlines blanks
|
||||||
|
|
||||||
hello: 01-hello-world.c
|
hello: 01-hello-world.c
|
||||||
gcc -o ./bin/01-helloworld 01-hello-world.c
|
gcc -o ./bin/01-helloworld 01-hello-world.c
|
||||||
@ -18,5 +18,8 @@ count: 05-char-counting.c
|
|||||||
countlines: 06-line-count.c
|
countlines: 06-line-count.c
|
||||||
gcc -o ./bin/06-line-count 06-line-count.c
|
gcc -o ./bin/06-line-count 06-line-count.c
|
||||||
|
|
||||||
|
blanks: 07-extra-blanks.c
|
||||||
|
gcc -o ./bin/07-extra-blanks 07-extra-blanks.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) ./bin/*-*
|
$(RM) ./bin/*-*
|
||||||
|
Loading…
Reference in New Issue
Block a user