2011年11月24日木曜日

[C 语言] codeblocks 配置使用 gnu readline

1. 使用 readline (设置 Linker)
1-1. 项目右键 -> Buil Options... -> Linker Settings -> Add -> OK
1-2. Settings -> Compiler and debugger... -> Global compiler settings -> Linker Settings -> Add -> OK
添加 readline, curses 等

2. 测试代码
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>

int main()
{
    char *ptr;
    using_history();
    read_history(NULL);
    while((ptr = readline("> ")))
    {
        add_history(ptr);
        puts(ptr);
        free(ptr);
    }
    write_history(NULL);

    return 0;
}

0 件のコメント:

コメントを投稿