diff options
| author | Dominik Kaiser | 2024-03-06 21:02:09 +0100 |
|---|---|---|
| committer | Dominik Kaiser | 2024-03-06 21:02:09 +0100 |
| commit | f861789c3e5e004395c1b7214757d5a83625d845 (patch) | |
| tree | 6eb15d263549018f639eb2b7fc5af6d621a39245 /ft_strchr.c | |
| download | libft-f861789c3e5e004395c1b7214757d5a83625d845.tar.gz libft-f861789c3e5e004395c1b7214757d5a83625d845.zip | |
Setup and current progress
Forgot to commit earlier...
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')); */ +/* } */ |
