lib: c: core: implement strchr and strcspn

This commit is contained in:
2026-03-25 20:21:28 +00:00
parent 96784f611f
commit 6787f28728
3 changed files with 35 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
#include <stddef.h>
char *strchr(const char *str, int c)
{
while (1) {
if (*str == c) {
return (char *)str;
}
if (*str == 0) {
break;
}
}
return NULL;
}
+15
View File
@@ -0,0 +1,15 @@
#include <stddef.h>
size_t strcspn(const char *dest, const char *src)
{
size_t i = 0;
for (i = 0; dest[i]; i++) {
for (size_t ii = 0; src[ii]; i++) {
if (dest[i] == src[ii]) {
return i;
}
}
}
return i;
}