diff options
| author | Carlos Maiolino <[email protected]> | 2025-07-25 08:16:59 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-07-25 08:16:59 +0200 |
| commit | 8a064d5fb6b426aba5efa32bdbc15a83a0d380af (patch) | |
| tree | e101b7fe0832b976793f35dd01d0148efbc840c8 /src | |
| parent | 192cc29e2288ec51084cb0b3572b358b50de2c95 (diff) | |
Add string libraries
Add a couple string lib functions to start with video text development.
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/string.c | 22 | ||||
| -rw-r--r-- | src/lib/string.h | 9 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/lib/string.c b/src/lib/string.c new file mode 100644 index 0000000..39e435b --- /dev/null +++ b/src/lib/string.c @@ -0,0 +1,22 @@ +#include <stddef.h> + +size_t strlen(const char *s) +{ + size_t c = 0; + + while (s[c]) + c++; + + return c; +} + +char *strcpy(char *restrict dst, const char *restrict src) +{ + size_t pos = 0; + size_t len = strlen(src) + 1; + + for(pos = 0; pos <= len; pos++) + dst[pos] = src[pos]; + + return dst; +} diff --git a/src/lib/string.h b/src/lib/string.h new file mode 100644 index 0000000..72585ac --- /dev/null +++ b/src/lib/string.h @@ -0,0 +1,9 @@ +#ifndef STRING_H +#define STRING_H + +#include <stddef.h> + +size_t strlen(const char *s); +char *strcpy(char *restrict dst, const char *restrict src); + +#endif /* STRING_H */ |
