CeDOS - Commit 4896349a

libcedos: Added rudimentary string.h
Celina Sophie Kalus
Sun, 26 Nov 2023 22:22:12 +0100
2 files changed, 30 insertions(+), 0 deletions(-)
A src/libcedos/include/string.h

@@ -0,0 +1,12 @@

+#ifndef STRING_H +#define STRING_H + +#include <stdint.h> + +typedef uint32_t size_t; + +void *memset(void *str, int c, size_t n); + +char * strcpy ( char * destination, const char * source ); + +#endif
A src/libcedos/string.c

@@ -0,0 +1,18 @@

+#include "string.h" +#include <stdint.h> + +void *memset(void *str, int c, size_t n) { + uint8_t *dest = str; + for (int i = 0; i < n; i++) { + dest[i] = c; + } +} + +char * strcpy ( char * destination, const char * source ) { + int i = 0; + + while (source[i]) { + destination[i] = source[i]; + i++; + } +}