Skip to content

Commit

Permalink
string: add strchr function
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Mazein <[email protected]>
Signed-off-by: Deepak Gupta <[email protected]>
  • Loading branch information
MegaMaddin committed Aug 26, 2020
1 parent 67660ec commit 35c171f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,19 @@ static inline int strcmp(const char *s1, const char *s2) {
return res;
}

static inline char *strchr(const char *s, int c) {
if (NULL == s)
return NULL;

while (*s != (char) c) {
if ('\0' == *s)
return NULL;
s++;
}

return (char *) s;
}

static inline int strncmp(const char *s1, const char *s2, size_t n) {
register char res;

Expand Down

0 comments on commit 35c171f

Please sign in to comment.