Parcourir la Source

rewrite using the editline library.

tiny line editing, dunno why we're not using readline, probably because
of some licensing stuff.
Lucas Stadler 11 ans auparavant
Parent
commit
41355ef886
2 fichiers modifiés avec 7 ajouts et 4 suppressions
  1. 1 1
      c/mul/Makefile
  2. 6 3
      c/mul/main.c

+ 1 - 1
c/mul/Makefile

@ -4,7 +4,7 @@ run: mul
4 4
	./mul
5 5
6 6
mul: main.c
7
	$(CC) main.c -o mul
7
	$(CC) -ledit main.c -o mul
8 8
9 9
clean:
10 10
	rm -f mul

+ 6 - 3
c/mul/main.c

@ -1,14 +1,17 @@
1 1
#include <stdio.h>
2 2
3
#include <editline/readline.h>
4
3 5
int main(int argc, char** argv) {
4 6
	puts("mul v0.0.1\n");
5 7
6 8
	while (1) {
7
		fputs("> ", stdout);
8
9
		fgets(input, 2048, stdin);
9
		char* input = readline("> ");
10
		add_history(input);
10 11
11 12
		printf("%s, yes.", input);
13
14
		free(input);
12 15
	}
13 16
14 17
	return 0;