use editline to read a line of input

This commit is contained in:
Josh Holtrop 2015-12-09 15:40:24 -05:00
parent f63f789c5d
commit 55c748944d
2 changed files with 17 additions and 4 deletions

10
Makefile Normal file
View File

@ -0,0 +1,10 @@
TARGET := main
CFLAGS := -Wall
LIBS := -leditline
OBJECTS := \
main.o
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(CC) -o $@ $(OBJECTS) $(LIBS)

11
main.c
View File

@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
char input[2048];
#include <editline.h>
int main(int argc, char * argv[])
{
@ -9,9 +10,11 @@ int main(int argc, char * argv[])
while (1)
{
printf("jlispy> ");
fflush(stdout);
fgets(input, sizeof(input), stdin);
char * input = readline("jlispy> ");
add_history(input);
printf("no you're a %s\n", input);
free(input);
}
return 0;
}