1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-13 11:04:27 -05:00

Main: libc/include/string.h: Add func "strchr"

This commit is contained in:
Alex Kotov 2022-06-10 09:13:23 +03:00
parent f5966c8079
commit 68f99ab59f
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 7 additions and 0 deletions

View file

@ -13,6 +13,7 @@ void *memmove(void *dest, const void *src, size_t n);
void *memchr(const void *s, int c, size_t n);
void *memset(void *s, int c, size_t n);
char *strcat(char *dest, const char *src);
char *strchr(const char *s, int c);
int strcmp(const char *s1, const char *s2);
char *strcpy(char *dest, const char *src);
size_t strlen(const char *s);

View file

@ -58,6 +58,12 @@ char *strcat(char *dest, const char *src)
return dest_start;
}
char *strchr(const char *s, int c)
{
for (; *s != (char)c; ++s) if (*s == '\0') return NULL;
return (char*)s;
}
int strcmp(const char *s1, const char *s2)
{
for (; *s1; ++s1, ++s2) if (*s1 != *s2) return *s1 < *s2 ? -1 : 1;