aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tests/readline.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/readline.c')
-rw-r--r--tests/readline.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/readline.c b/tests/readline.c
new file mode 100644
index 0000000..a27de67
--- /dev/null
+++ b/tests/readline.c
@@ -0,0 +1,30 @@
1
2#include <stdio.h>
3#include <string.h>
4#include <readline/readline.h>
5#include <readline/history.h>
6
7int main(void);
8
9int main(void)
10{
11 char * data;
12 char * old;
13
14 data = strdup("");
15
16 while(strcmp(data, "exit"))
17 {
18 old = data;
19 printf("Enter text [%s]: ", data);
20 data = readline(NULL);
21 if(!(strlen(data)))
22 data = old;
23 else
24 free(old);
25 printf("you typed: %s\n", data);
26 old = data;
27 };
28
29 return(0);
30}