Implemented strcat() and strchr()
This commit is contained in:
@@ -12,6 +12,8 @@ extern int memcmp(const void *a, const void *b, size_t sz);
|
||||
extern void *memmove(void *dest, const void *src, size_t sz);
|
||||
extern void *memset(void *ptr, int value, size_t sz);
|
||||
|
||||
extern char *strcat(char *dest, const char *src);
|
||||
|
||||
extern size_t strlen(const char *str);
|
||||
extern int strcmp(const char *a, const char *b);
|
||||
extern int strncmp(const char *a, const char *b, size_t sz);
|
||||
@@ -19,6 +21,7 @@ extern int strncmp(const char *a, const char *b, size_t sz);
|
||||
extern char *strcpy(char *dest, const char *src);
|
||||
extern char *strncpy(char *dest, const char *src, size_t sz);
|
||||
|
||||
extern char *strchr(const char *str, int ch);
|
||||
extern char *strrchr(const char *s, int c);
|
||||
extern size_t strcspn(const char *str1, const char *str2);
|
||||
|
||||
|
||||
8
photon/libc/string/strcat.c
Normal file
8
photon/libc/string/strcat.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <string.h>
|
||||
|
||||
char *strcat(char *dest, const char *src)
|
||||
{
|
||||
size_t len = strlen(dest);
|
||||
strcpy(dest + len, src);
|
||||
return dest;
|
||||
}
|
||||
14
photon/libc/string/strchr.c
Normal file
14
photon/libc/string/strchr.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <string.h>
|
||||
|
||||
char *strchr(const char *str, int ch)
|
||||
{
|
||||
char c = ch;
|
||||
|
||||
for (size_t i = 0; str[i]; i++) {
|
||||
if (str[i] == c) {
|
||||
return (char *)&str[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user