简单readline使用
wln@iZ232ngsvp8Z:~/tmp> gcc -g -o readline readline.c -lreadline -lncurses
wln@iZ232ngsvp8Z:~/tmp> ./readline
postgres#pwd
pwd
postgres#quit
quit
wln@iZ232ngsvp8Z:~/tmp> cat readline.c
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
int main(void)
{
char *buf;
//memset(buf, 0, 256);
buf=(char *)malloc(sizeof(char)*256);
while(1)
{
buf = readline("postgres#");
if(buf != NULL)
puts(buf);
if(strcasecmp(buf,"quit")==0)
break;
}
exit(0);
}
1. 阅读
GNU readline 库及编程简介
http://www.cnblogs.com/hazir/p/instruction_to_readline.html
因篇幅问题不能全部显示,请点此查看更多更全内容