libft / ft_strlcpy.c 109 commits
14-04-2026
26 lines 1.1 kB
 1/* ************************************************************************** */
 2/*                                                                            */
 3/*                                                        :::      ::::::::   */
 4/*   ft_strlcpy.c                                       :+:      :+:    :+:   */
 5/*                                                    +:+ +:+         +:+     */
 6/*   By: mleitao <mleitao@student.42.fr>            +#+  +:+       +#+        */
 7/*                                                +#+#+#+#+#+   +#+           */
 8/*   Created: 2026/03/09 22:48:32 by mleitao           #+#    #+#             */
 9/*   Updated: 2026/04/14 19:22:56 by mleitao          ###   ########.fr       */
10/*                                                                            */
11/* ************************************************************************** */
12
13#include "libft.h"
14
15size_t	ft_strlcpy(char *dst, const char *src, size_t size)
16{
17	size_t	src_len;
18
19	src_len = ft_strlen(src);
20	if (size == 0)
21		return (src_len);
22	while (*src && size-- > 1)
23		*dst++ = *src++;
24	*dst = '\0';
25	return (src_len);
26}