mirror of
https://github.com/krislamo/knrc.git
synced 2025-01-07 03:50:36 +00:00
Line counting example
This commit is contained in:
parent
3512ae49ab
commit
6bf093f44f
12
06-line-count.c
Normal file
12
06-line-count.c
Normal 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);
|
||||
}
|
5
Makefile
5
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/*-*
|
||||
|
Loading…
Reference in New Issue
Block a user