summaryrefslogtreecommitdiff
path: root/libft/ft_strchr.c
blob: ecf522e0d604b3618d1a5b2f79ea9280cf0d4443 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_strchr.c                                        :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: dkaiser <dkaiser@student.42heilbronn.de    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2024/03/06 14:12:39 by dkaiser           #+#    #+#             */
/*   Updated: 2024/03/10 13:15:56 by dkaiser          ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "libft.h"

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++;
	}
	if (!(char)c)
		return ((char *)&s[i]);
	return (0);
}

/* #include <stdio.h> */
/* #include <string.h> */

/* int	main(void) */
/* { */
/* 	char	str[] = "teste"; */

/* 	printf("strchr: %p\n", strchr(str, '\0')); */
/* 	printf("ft_strchr: %p\n", ft_strchr(str, '\0')); */
/* } */