diff options
| author | Abdellah El Morabit <nsrddyn@gmail.com> | 2025-01-30 21:07:16 +0100 |
|---|---|---|
| committer | Abdellah El Morabit <nsrddyn@gmail.com> | 2025-01-30 21:08:17 +0100 |
| commit | 8650f2d46dc6df62fcf70d4b769746987e748830 (patch) | |
| tree | 89223d3e6b957f47da4e15f40949a26c18d48539 /main.c | |
Learning about getting the commands history and
actually saving them, having trouble doing it in c
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <stdbool.h> +#include <readline/history.h> +#include <readline/readline.h> + +int main() { + const bool RUNNING = true; + char *COMMAND_HISTORY; + COMMAND_HISTORY = (char *)malloc(sizeof(char)); + + + // RUNNING THE PROGRAM ON AN ENDLESS LOOP + // BREAKS WHEN USER ENTERS EXIT + while(RUNNING) { + char *TEMP = ""; + + scanf("%s", &TEMP); + for (int i = 0; i != "/0"; i++) + { + tolower(TEMP[0]); + } + + if (TEMP == "exit") { + RUNNING = false; + printf("exited successfully"); + } + else { + strcpy(&TEMP, (COMMAND_HISTORY)); + printf("%s",COMMAND_HISTORY); + } + + } + return 0; +} |
