diff --git a/06-line-count.c b/06-line-count.c new file mode 100644 index 0000000..f7338b5 --- /dev/null +++ b/06-line-count.c @@ -0,0 +1,12 @@ +#include + +int main() +{ + int c, n1; + + n1 = 0; + while ((c = getchar ()) != EOF) + if (c == '\n') + ++n1; + printf("%d\n", n1); +} diff --git a/Makefile b/Makefile index e60db29..7e067df 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: hello mathvars c2f input count +all: hello mathvars c2f input count countlines hello: 01-hello-world.c gcc -o ./bin/01-helloworld 01-hello-world.c @@ -15,5 +15,8 @@ input: 04-file-copying.c count: 05-char-counting.c gcc -o ./bin/05-count 05-char-counting.c +countlines: 06-line-count.c + gcc -o ./bin/06-line-count 06-line-count.c + clean: $(RM) ./bin/*-*