use editline to read a line of input
This commit is contained in:
parent
f63f789c5d
commit
55c748944d
10
Makefile
Normal file
10
Makefile
Normal 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
11
main.c
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user