diff options
Diffstat (limited to 'ft_strchr.c')
| -rw-r--r-- | ft_strchr.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ft_strchr.c b/ft_strchr.c new file mode 100644 index 0000000..e53f78e --- /dev/null +++ b/ft_strchr.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/03/06 14:12:39 by dkaiser #+# #+# */ +/* Updated: 2024/03/06 14:35:37 by dkaiser ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strchr(const char *s, int c) +{ + int i; + + i = 0; + while (s[i] != '\0') + { + if (s[i] == (char)c) + return ((char *)&s[i]); + i++; + } + return (0); +} + +/* #include <stdio.h> */ +/* #include <string.h> */ +/* int main() { */ +/* char str[] = "Hello world"; */ +/* printf("strchr: %s\n", strchr(str, 'o')); */ +/* printf("ft_strchr: %s\n", ft_strchr(str, 'o')); */ +/* } */ |
