use editline to read a line of input
This commit is contained in:
1 parent
f63f789c5d
commit
55c748944d
2 files changed
+17
-4
No files matched your search
@@ -0,0 +1,10 @@
|
|||||||
|
TARGET := main
|
||||||
|
CFLAGS := -Wall
|
||||||
|
LIBS := -leditline
|
||||||
|
OBJECTS := \
|
||||||
|
main.o
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
$(TARGET): $(OBJECTS)
|
||||||
|
$(CC) -o $@ $(OBJECTS) $(LIBS)
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
char input[2048];
|
#include <editline.h>
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
@@ -9,9 +10,11 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
printf("jlispy> ");
|
char * input = readline("jlispy> ");
|
||||||
fflush(stdout);
|
add_history(input);
|
||||||
fgets(input, sizeof(input), stdin);
|
|
||||||
printf("no you're a %s\n", input);
|
printf("no you're a %s\n", input);
|
||||||
|
free(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user