aboutsummaryrefslogtreecommitdiffstats
path: root/libft/src/ft_strnlen.c
blob: 325fa0df3dd31975b5ea6daa6fc4046bbede8c71 (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
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_strnlen.c                                       :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:07:14 by rbousset          #+#    #+#             */
/*   Updated: 2020/02/14 17:07:14 by rbousset         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <stddef.h>

size_t
	ft_strnlen(const char *s, size_t size)
{
	const char *ptr = s;

	while (size > 0 && *ptr)
	{
		size--;
		ptr++;
	}
	return (ptr - s);
}