aboutsummaryrefslogtreecommitdiff
path: root/ft_strchr.c
blob: 048b2ecd0c27dabc8dab08cefc3cfa383a0afb42 (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
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_strchr.c                                        :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2019/10/07 10:14:47 by cacharle          #+#    #+#             */
/*   Updated: 2019/10/07 10:40:04 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <stdlib.h>

char	*ft_strchr(const char *s, int c)
{
	char	*cursor;

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