From 8650f2d46dc6df62fcf70d4b769746987e748830 Mon Sep 17 00:00:00 2001 From: Abdellah El Morabit Date: Thu, 30 Jan 2025 21:07:16 +0100 Subject: Learning about getting the commands history and actually saving them, having trouble doing it in c --- main.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 main.c (limited to 'main.c') diff --git a/main.c b/main.c new file mode 100644 index 0000000..504439b --- /dev/null +++ b/main.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include +#include +#include + +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; +} -- cgit v1.2.3-70-g09d2