#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <readline/readline.h>
#include <readline/history.h>
int main()
{
char *combuf;
//禁止 TAB 键的自动完成功能
rl_bind_key('\t', rl_abort);
while((combuf = readline("\n > ")) != NULL) {
if (strncmp(combuf, "quit", 4) == 0)
break;
printf ("[%s]\n", combuf);
if (combuf[0] != 0)
add_history(combuf); //将输入过的命令增加到历史记录
}
free(combuf);
return 0;
}
beyes@beyes :~/c/readline> ./com_his
> hello
[hello]
> hisll
[hisll]
> shell
[shell]
> find
[find]
> which
[which]
> quit
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |