C_C++
Cerbian
Tcl
anon_-_poller
autoconfig
bison
compile_times
cpp_zh
emil_header_guards
flex
linking
sds
1st_day_of_month.cpp
JJbY.cpp
Tp6G.cpp
alternatice_bracket.c
arrows.cpp
auto_variad.c
c.php
c_old_argument_notation.c
cnn.c
comment_as_space.c
comp.c
conditional_const.c
const.c
cpp_regex_error.cpp
current_year.cpp
dda2.cpp
dog.jpg
dog2.jpg
eh.cpp
else_while.c
for_ctags.cpp
for_nop_true.c
free_null.c
function_pointer_strategy.c
function_pointer_strategy2.c
gcc_include_next.c
gdb_graph.c
getopt_test.c
getter_example.cpp
gnu_decimals.c
gnu_history.c
gnu_regex.c
gnu_regex2.c
header.h
index_in_initializer_list_compiler_extension.c
is_this_what_you_are_asking_emil.c
knr.c
levenshtein_dist_-_usage.cpp
macro_paren.c
magic.c
manual_unrolling.c
map_initialization.cpp
ncurses_labels.c
ncurses_mv_win.cpp
ncurses_plus_readline.cpp
ncurses_resize2.cpp
ncurses_resize_hello_world.cpp
ncurses_resize_test.c
ncurses_scroll.c
nf.c
null_printf.c
null_printf.cpp
portable_namespace.c
portable_namespace.h
printf_star.c
pta.c
raylib_hw.cpp
scoping_showcase.c
screen_size_(without_curses).c
sdl_render_to_texture.cpp
self_pointer.c
sentinel_pack.c
setjmp_test.cpp
signals.c
strategiless.c
strdup.c
tcc_int.c
test.c
typedef.c
unctrl.c
undefined_reference.c
usb.c
vasprintf.c
void_main.c
x.cpp
xtermio.c
xtp.cpp
Haskell
Java
LaTeX
Misc.
Python
Vim
Webdev
git
.gitignore
Makefile
24 lines
593 B
C
24 lines
593 B
C
// @COMPILECMD gcc $@ -lreadline -lhistory
|
|
#include <stdio.h>
|
|
#include <readline/readline.h>
|
|
#include <readline/history.h>
|
|
|
|
int main() {
|
|
using_history(); // Initialize history
|
|
|
|
char *input;
|
|
while ((input = readline("Enter your command: ")) != NULL) {
|
|
if (input[0] != '\0') {
|
|
add_history(input); // Add to history
|
|
// Process and handle input here
|
|
printf("You entered: %s\n", input);
|
|
}
|
|
free(input); // Free allocated memory
|
|
}
|
|
|
|
// Save history to a file (optional)
|
|
write_history("history.txt");
|
|
|
|
return 0;
|
|
}
|