1
0
mirror of https://github.com/krislamo/knrc.git synced 2024-09-19 21:00:35 +00:00

Line counting example

This commit is contained in:
Kris Lamoureux 2021-11-09 00:36:42 -05:00
parent 3512ae49ab
commit 6bf093f44f
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
2 changed files with 16 additions and 1 deletions

12
06-line-count.c Normal file
View File

@ -0,0 +1,12 @@
#include <stdio.h>
int main()
{
int c, n1;
n1 = 0;
while ((c = getchar ()) != EOF)
if (c == '\n')
++n1;
printf("%d\n", n1);
}

View File

@ -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/*-*