Compare commits
No commits in common. "dd31852c69846ac5d222b9a06287e8bf48ade31f" and "9c41981502f085e20dfd9f4ef322d430d9500721" have entirely different histories.
dd31852c69
...
9c41981502
10 changed files with 3 additions and 42 deletions
11
Makefile
11
Makefile
|
@ -1,14 +1,9 @@
|
||||||
CC := cc -g -Wall -Wextra -Werror -ansi
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
|
||||||
all: out out/sh out/wc
|
all: out out/sh
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mkdir -p -- $@
|
mkdir -p -- $@
|
||||||
|
|
||||||
out/sh: $(wildcard src/sh/*.c)
|
out/sh: $(wildcard src/*.c)
|
||||||
$(CC) -o $@ $^
|
cc -g -Wall -Wextra -Werror -ansi -o $@ $^
|
||||||
|
|
||||||
out/wc: $(wildcard src/wc/*.c)
|
|
||||||
$(CC) -o $@ $^
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
recreations
|
|
||||||
====
|
|
||||||
|
|
||||||
A repo where I drop all program recreations I can.
|
|
|
@ -1,30 +0,0 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
FILE *file;
|
|
||||||
if (argc > 1 && strcmp(argv[1], "-")) {
|
|
||||||
file = fopen(argv[1], "rb");
|
|
||||||
if (file == NULL) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
file = stdin;
|
|
||||||
}
|
|
||||||
|
|
||||||
int current = fgetc(file);
|
|
||||||
unsigned int nb_lines = 0;
|
|
||||||
|
|
||||||
while (current != EOF) {
|
|
||||||
if (current == '\n') {
|
|
||||||
nb_lines++;
|
|
||||||
}
|
|
||||||
|
|
||||||
current = fgetc(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
printf("%d\n", nb_lines);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in a new issue