KLIBC string.h: strcmp, strcpy, strlen, strcat

This commit is contained in:
noverd 2025-01-13 18:37:24 +03:00
parent f5ee0f8274
commit 67a604a6c4
2 changed files with 16 additions and 3 deletions

View File

@ -1,5 +1,6 @@
#include <khal.h>
#include <kstdint.h>
#include <kstring.h>
int multiboot2_init(uint64_t *addr, uint32_t magic);
@ -14,6 +15,18 @@ void kernel_main64(uint64_t *multiboot2, uint32_t magic, void *esp, uint64_t bas
} else {
serial_printf("[ERR]\n");
}
char *str1 = "ABCF";
char *str2 = "ABCD";
char buf[7] = "";
auto cmp_value = strcmp(str1, str2);
serial_printf("[LOG] STR1 AND STR2 CMP %d\n", cmp_value);
serial_printf("[LOG] STR1 LEN %d\n", strlen(str1));
strcpy((char*)&buf, str1);
serial_printf("[LOG] STRCPY RESULT: %s\n", buf);
serial_printf("[LOG] STRCPY RESULT LEN %d\n", strlen(buf));
strcat((char*)&buf, "CAT");
serial_printf("[LOG] STRCAT RESULT: %s\n", buf);
serial_printf("[LOG] STRCAT RESULT LEN %d\n", strlen(buf));
for (;;) {}
}
}

View File

@ -77,4 +77,4 @@ void serial_printf(const char *fmt, ...) {
}
}
va_end(args);
}
}