Edit

kc3-lang/linenoise/example.c

Branch :

  • Show log

    Commit

  • Author : antirez
    Date : 2010-07-07 18:26:23
    Hash : ce845468
    Message : Support API to save/load history on file

  • example.c
  • #include <stdio.h>
    #include <stdlib.h>
    #include "linenoise.h"
    
    int main(void) {
        char *line;
    
        linenoiseHistoryLoad("history.txt"); /* Load the history at startup */
        while((line = linenoise("hello> ")) != NULL) {
            if (line[0] != '\0') {
                printf("echo: '%s'\n", line);
                linenoiseHistoryAdd(line);
                linenoiseHistorySave("history.txt"); /* Save every new entry */
            }
            free(line);
        }
        return 0;
    }