readline库的使用
来源:互联网 发布:罗振宇人工智能视频 编辑:程序博客网 时间:2024/05/16 06:46
接口十分简单,readline和addhistory:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
int main()
{
char* input, shell_prompt[100];
// Configure readline to auto-complete paths when the tab key is hit.
rl_bind_key('\t', rl_complete);
for(;;) {
// Create prompt string from user name and current working directory.
snprintf(shell_prompt, sizeof(shell_prompt), "%s:%s $ ", getenv("USER"), getcwd(NULL, 1024));
// Display prompt and read input (n.b. input must be freed after use)...
input = readline(shell_prompt);
// Check for EOF.
if (!input)
break;
// Add input to history.
add_history(input);
// Do stuff...
// Free input.
free(input);
}
}
g++ TestReadLine.cc -lreadline就可以了。
- readline库的使用
- LINUX readline 库的使用,,
- readline库函数的使用
- readline的使用
- readline( )库的安装和使用,实现命令补全
- readline( )库的安装和使用,实现命令补全
- read(), readline(), readlines()方法的使用
- read(), readline(), readlines()方法的使用
- NodeJS基础:readline模块的使用
- 使用readLine()方法遇到的坑
- 使用bufferedreader 的readline()读取文件
- readline库
- 增强命令输入的用户交互性--readline库的使用
- Bash readline 使用技巧
- BufferedReader使用readLine问题
- readline使用示例
- Bash readline 使用技巧
- 关于StreamReader的ReadLine中Trim的使用
- windows下cmd命令编译C++
- 跨平台的游戏客户端Socket封装
- mysql+php实现选课系统中遇到的问题及解决方法
- linux内核可变参数分析
- Future APP
- readline库的使用
- uva 311
- VC 模式对话框和非模式对话框的创建,销毁和区别
- linux rsync使用笔记
- int i = -2147483648 后面的事情
- iOS8 定位问题
- 工作流系统关系设计
- Git 基本命令
- apache和tomcat有什么不同,为什么要整合apache 和tomcat?