Adding printf & strcpy
This commit is contained in:
parent
c1790da4b4
commit
e1d33272f7
13 changed files with 385 additions and 67 deletions
70
Makefile
70
Makefile
|
|
@ -6,7 +6,7 @@
|
|||
# By: rparodi <marvin@42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||
# Updated: 2024/10/31 12:39:34 by rparodi ### ########.fr #
|
||||
# Updated: 2024/10/31 16:15:59 by rparodi ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -33,48 +33,52 @@ LDLIBS = -lft
|
|||
INCLUDES = ./includes/
|
||||
|
||||
SRC = char/ft_isdigit.c \
|
||||
char/ft_isalnum.c \
|
||||
char/ft_isalpha.c \
|
||||
char/ft_isascii.c \
|
||||
char/ft_isprint.c \
|
||||
char/ft_toupper.c \
|
||||
char/ft_isalpha.c \
|
||||
char/ft_isalnum.c \
|
||||
char/ft_tolower.c \
|
||||
memory/ft_memcmp.c \
|
||||
memory/ft_bzero.c \
|
||||
memory/ft_memcpy.c \
|
||||
memory/ft_memchr.c \
|
||||
memory/ft_memset.c \
|
||||
memory/ft_memmove.c \
|
||||
memory/ft_calloc.c \
|
||||
print/ft_putstr_fd.c \
|
||||
print/ft_putnbr_fd.c \
|
||||
print/ft_putendl_fd.c \
|
||||
print/ft_putchar_fd.c \
|
||||
char/ft_toupper.c \
|
||||
convert/ft_atoi.c \
|
||||
convert/ft_atoll.c \
|
||||
convert/ft_itoa.c \
|
||||
list/ft_lstadd_back.c \
|
||||
list/ft_lstnew.c \
|
||||
list/ft_lstlast.c \
|
||||
list/ft_lstclear.c \
|
||||
list/ft_lstiter.c \
|
||||
list/ft_lstmap.c \
|
||||
list/ft_lstsize.c \
|
||||
list/ft_lstadd_front.c \
|
||||
list/ft_lstclear.c \
|
||||
list/ft_lstdelone.c \
|
||||
str/ft_strnstr.c \
|
||||
str/ft_strlcpy.c \
|
||||
str/ft_strlen.c \
|
||||
list/ft_lstiter.c \
|
||||
list/ft_lstlast.c \
|
||||
list/ft_lstmap.c \
|
||||
list/ft_lstnew.c \
|
||||
list/ft_lstsize.c \
|
||||
memory/ft_bzero.c \
|
||||
memory/ft_calloc.c \
|
||||
memory/ft_memchr.c \
|
||||
memory/ft_memcmp.c \
|
||||
memory/ft_memcpy.c \
|
||||
memory/ft_memmove.c \
|
||||
memory/ft_memset.c \
|
||||
print/ft_printf.c \
|
||||
print/ft_put.c \
|
||||
print/ft_putchar_fd.c \
|
||||
print/ft_putendl_fd.c \
|
||||
print/ft_putnbr_fd.c \
|
||||
print/ft_putstr_fd.c \
|
||||
str/ft_split.c \
|
||||
str/ft_strchr.c \
|
||||
str/ft_strcpy.c \
|
||||
str/ft_strdup.c \
|
||||
str/ft_striteri.c \
|
||||
str/ft_strjoin.c \
|
||||
str/ft_split.c \
|
||||
str/ft_strrchr.c \
|
||||
str/ft_substr.c \
|
||||
str/ft_strncmp.c \
|
||||
str/ft_strmapi.c \
|
||||
str/ft_strtrim.c \
|
||||
str/ft_strlcat.c \
|
||||
str/ft_strdup.c \
|
||||
convert/ft_atoi.c \
|
||||
convert/ft_itoa.c
|
||||
str/ft_strlcpy.c \
|
||||
str/ft_strlen.c \
|
||||
str/ft_strmapi.c \
|
||||
str/ft_strncmp.c \
|
||||
str/ft_strnstr.c \
|
||||
str/ft_strrchr.c \
|
||||
str/ft_strtrim.c \
|
||||
str/ft_substr.c
|
||||
|
||||
# Objects
|
||||
OBJDIRNAME = ./objects
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/08 17:22:41 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 13:02:58 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 15:16:10 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
60
convert/ft_atoll.c
Normal file
60
convert/ft_atoll.c
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_atoll.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:12:07 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:14:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
static int ft_check_space(int c)
|
||||
{
|
||||
if (c == 32 || (c >= 9 && c <= 13))
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int ft_check_sign(const char *nptr, size_t *i)
|
||||
{
|
||||
while (ft_check_space(nptr[*i]))
|
||||
(*i)++;
|
||||
if (nptr[*i] == '-')
|
||||
{
|
||||
(*i)++;
|
||||
return (-1);
|
||||
}
|
||||
else if (nptr[*i] == '+')
|
||||
(*i)++;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Converts string to long long integer
|
||||
*
|
||||
* @param nptr the string that will be converted
|
||||
* @return The long long int on the string
|
||||
*/
|
||||
long long int ft_atoll(const char *nptr)
|
||||
{
|
||||
size_t i;
|
||||
int sign;
|
||||
long long int number;
|
||||
|
||||
i = 0;
|
||||
sign = ft_check_sign(nptr, &i);
|
||||
number = 0;
|
||||
while (nptr[i])
|
||||
{
|
||||
if (nptr[i] >= '0' && nptr[i] <= '9')
|
||||
number = (number * 10) + nptr[i] - '0';
|
||||
else
|
||||
break ;
|
||||
i++;
|
||||
}
|
||||
return (sign * number);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 14:54:04 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:10:21 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 15:22:26 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -20,12 +20,12 @@
|
|||
# include <limits.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
int ft_isalpha(int c);
|
||||
int ft_isdigit(int c);
|
||||
int ft_isalnum(int c);
|
||||
int ft_isalpha(int c);
|
||||
int ft_isascii(int c);
|
||||
int ft_isdigit(int c);
|
||||
int ft_isprint(int c);
|
||||
int ft_toupper(int c);
|
||||
int ft_tolower(int c);
|
||||
int ft_toupper(int c);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 14:57:24 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:10:01 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 15:27:40 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
# include <limits.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
|
||||
int ft_atoi(const char *nptr);
|
||||
char *ft_itoa(int n);
|
||||
char *ft_itoa(int n);
|
||||
int ft_atoi(const char *nptr);
|
||||
long long int ft_atoll(const char *nptr);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,17 +6,18 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/06 11:14:57 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:09:36 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 15:27:14 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LIBFT_H
|
||||
# define LIBFT_H
|
||||
|
||||
#include "char.h"
|
||||
#include "convert.h"
|
||||
#include "list.h"
|
||||
#include "print.h"
|
||||
#include "str.h"
|
||||
# include "char.h"
|
||||
# include "convert.h"
|
||||
# include "list.h"
|
||||
# include "memory.h"
|
||||
# include "print.h"
|
||||
# include "str.h"
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:00:12 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:10:06 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 15:27:20 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -26,15 +26,14 @@ typedef struct s_list
|
|||
struct s_list *next;
|
||||
} t_list;
|
||||
|
||||
int ft_lstsize(t_list *lst);
|
||||
t_list *ft_lstlast(t_list *lst);
|
||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
|
||||
t_list *ft_lstnew(void *content);
|
||||
void ft_lstadd_back(t_list **lst, t_list *new);
|
||||
void ft_lstadd_front(t_list **lst, t_list *new);
|
||||
void ft_lstclear(t_list **lst, void (*del)(void *));
|
||||
void ft_lstdelone(t_list *lst, void (*del)(void *));
|
||||
void ft_lstiter(t_list *lst, void (*f)(void *));
|
||||
t_list *ft_lstlast(t_list *lst);
|
||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
|
||||
t_list *ft_lstnew(void *content);
|
||||
int ft_lstsize(t_list *lst);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
31
includes/memory.h
Normal file
31
includes/memory.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* memory.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:18:17 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:21:00 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MEMORY_H
|
||||
# define MEMORY_H
|
||||
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <limits.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
int ft_memcmp(const void *s1, const void *s2, size_t n);
|
||||
void *ft_calloc(size_t nmemb, size_t size);
|
||||
void *ft_memchr(const void *s, int c, size_t n);
|
||||
void *ft_memcpy(void *dest, const void *src, size_t n);
|
||||
void *ft_memmove(void *dest, const void *src, size_t n);
|
||||
void *ft_memset(void *s, int c, size_t n);
|
||||
void ft_bzero(void *s, size_t n);
|
||||
|
||||
#endif
|
||||
|
|
@ -6,20 +6,23 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:07:30 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:08:28 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 15:41:54 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PRINT_H
|
||||
# define PRINT_H
|
||||
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <limits.h>
|
||||
# include <fcntl.h>
|
||||
# include <limits.h>
|
||||
# include <stdarg.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <unistd.h>
|
||||
|
||||
int ft_dprintf(int fd, const char *s, ...);
|
||||
int ft_printf(const char *s, ...);
|
||||
void ft_putchar_fd(char c, int fd);
|
||||
void ft_putendl_fd(char *s, int fd);
|
||||
void ft_putnbr_fd(int n, int fd);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 15:04:59 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 15:10:12 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/10/31 16:15:39 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -20,13 +20,9 @@
|
|||
# include <limits.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
int ft_strncmp(const char *s1, const char *s2, size_t n);
|
||||
size_t ft_strlcat(char *dst, const char *src, size_t size);
|
||||
size_t ft_strlcpy(char *dst, const char *src, size_t size);
|
||||
size_t ft_strlen(const char *s);
|
||||
void ft_striteri(char *s, void (*f)(unsigned int, char*));
|
||||
char **ft_split(char const *s, char c);
|
||||
char *ft_strchr(const char *s, int c);
|
||||
char *ft_strcpy(char *dst, const char *src);
|
||||
char *ft_strdup(const char *s);
|
||||
char *ft_strjoin(char const *s1, char const *s2);
|
||||
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
|
||||
|
|
@ -34,6 +30,10 @@ char *ft_strnstr(const char *big, const char *little, size_t len);
|
|||
char *ft_strrchr(const char *s, int c);
|
||||
char *ft_strtrim(char const *s1, char const *set);
|
||||
char *ft_substr(char const *s, unsigned int start, size_t len);
|
||||
int ft_strncmp(const char *s1, const char *s2, size_t n);
|
||||
size_t ft_strlcat(char *dst, const char *src, size_t size);
|
||||
size_t ft_strlcpy(char *dst, const char *src, size_t size);
|
||||
size_t ft_strlen(const char *s);
|
||||
void ft_striteri(char *s, void (*f)(unsigned int, char*));
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
96
print/ft_printf.c
Normal file
96
print/ft_printf.c
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_printf.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/14 17:27:44 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 16:12:37 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void _print_char(int fd, char c, int *ret_value);
|
||||
void _print_nbr(int fd, int nb, int *ret_value);
|
||||
void _print_base(\
|
||||
int fd, unsigned long long nbr, int *ret_value, char c);
|
||||
void _print_unsigned(int fd, unsigned int nb, int *ret_value);
|
||||
void _print_str(int fd, char *str, int *ret_value);
|
||||
|
||||
int _check_args(int fd, char c, va_list args, int *ret_value)
|
||||
{
|
||||
if (c == 'c')
|
||||
_print_char(fd, (char)va_arg(args, int), ret_value);
|
||||
else if (c == 's')
|
||||
_print_str(fd, (char *)va_arg(args, char *), ret_value);
|
||||
else if (c == 'i' || c == 'd')
|
||||
_print_nbr(fd, (int)va_arg(args, int), ret_value);
|
||||
else if (c == '%')
|
||||
_print_char(fd, '%', ret_value);
|
||||
else if (c == 'u')
|
||||
_print_unsigned(\
|
||||
fd, (unsigned int)va_arg(args, unsigned int), ret_value);
|
||||
else if (c == 'x')
|
||||
_print_base(fd, (unsigned int)va_arg(args, unsigned int), ret_value, c);
|
||||
else if (c == 'X')
|
||||
_print_base(fd, (unsigned int)va_arg(args, unsigned int), ret_value, c);
|
||||
else if (c == 'p')
|
||||
_print_base(fd, (unsigned long long)va_arg(args, unsigned long long), \
|
||||
ret_value, c);
|
||||
va_end(args);
|
||||
return (1);
|
||||
}
|
||||
|
||||
int ft_dprintf(int fd, const char *s, ...)
|
||||
{
|
||||
size_t i;
|
||||
va_list args;
|
||||
char *str;
|
||||
int ret_value;
|
||||
|
||||
ret_value = 0;
|
||||
str = ft_strdup(s);
|
||||
va_start(args, s);
|
||||
i = 0;
|
||||
while (str[i])
|
||||
{
|
||||
if (str[i] == '%')
|
||||
{
|
||||
_check_args(fd, str[i + 1], args, &ret_value);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
_print_char(fd, str[i], &ret_value);
|
||||
i++;
|
||||
}
|
||||
free(str);
|
||||
return (ret_value);
|
||||
}
|
||||
|
||||
int ft_printf(const char *s, ...)
|
||||
{
|
||||
size_t i;
|
||||
va_list args;
|
||||
char *str;
|
||||
int ret_value;
|
||||
|
||||
ret_value = 0;
|
||||
str = ft_strdup(s);
|
||||
va_start(args, s);
|
||||
i = 0;
|
||||
while (str[i])
|
||||
{
|
||||
if (str[i] == '%')
|
||||
{
|
||||
_check_args(1, str[i + 1], args, &ret_value);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
_print_char(1, str[i], &ret_value);
|
||||
i++;
|
||||
}
|
||||
free(str);
|
||||
return (ret_value);
|
||||
}
|
||||
97
print/ft_put.c
Normal file
97
print/ft_put.c
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_put.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/16 12:13:14 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 16:16:45 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void _print_char(int fd, char c, int *ret_value);
|
||||
void _print_nbr(int fd, int nb, int *ret_value);
|
||||
void _print_base(\
|
||||
int fd, unsigned long long nbr, int *ret_value, char c);
|
||||
void _print_unsigned(int fd, unsigned int nb, int *ret_value);
|
||||
void _print_str(int fd, char *str, int *ret_value);
|
||||
|
||||
void _print_char(int fd, char c, int *ret_value)
|
||||
{
|
||||
write(fd, &c, 1);
|
||||
(*ret_value)++;
|
||||
}
|
||||
|
||||
void _print_nbr(int fd, int nb, int *ret_value)
|
||||
{
|
||||
if (nb < 0)
|
||||
{
|
||||
if (nb == INT_MIN)
|
||||
{
|
||||
write(1, "-2147483648", 11);
|
||||
*ret_value += 11;
|
||||
return ;
|
||||
}
|
||||
nb = -nb;
|
||||
_print_char(fd, '-', ret_value);
|
||||
}
|
||||
if (nb >= 10)
|
||||
{
|
||||
_print_nbr(fd, nb / 10, ret_value);
|
||||
nb = nb % 10;
|
||||
}
|
||||
if (nb < 10)
|
||||
_print_char(fd, nb + 48, ret_value);
|
||||
}
|
||||
|
||||
void _print_base(\
|
||||
int fd, unsigned long long nbr, int *ret_value, char c)
|
||||
{
|
||||
char base[16];
|
||||
|
||||
if (c == 'x' || c == 'q')
|
||||
ft_strcpy(base, "0123456789abcdef");
|
||||
else if (c == 'X')
|
||||
ft_strcpy(base, "0123456789ABCDEF");
|
||||
else if (c == 'p')
|
||||
{
|
||||
if (nbr != 0)
|
||||
_print_str(fd, "0x", ret_value);
|
||||
else if (nbr == 0)
|
||||
{
|
||||
_print_str(fd, "(nil)", ret_value);
|
||||
return ;
|
||||
}
|
||||
else
|
||||
ft_strcpy(base, "0123456789abcdef");
|
||||
c++;
|
||||
}
|
||||
if (c != 'p')
|
||||
{
|
||||
if (nbr >= 16)
|
||||
_print_base(fd, nbr / 16, ret_value, c);
|
||||
_print_char(fd, base[nbr % 16], ret_value);
|
||||
}
|
||||
}
|
||||
|
||||
void _print_unsigned(int fd, unsigned int nb, int *ret_value)
|
||||
{
|
||||
if (nb >= 10)
|
||||
{
|
||||
_print_unsigned(fd, nb / 10, ret_value);
|
||||
nb = nb % 10;
|
||||
}
|
||||
if (nb < 10)
|
||||
_print_char(fd, nb + 48, ret_value);
|
||||
}
|
||||
|
||||
void _print_str(int fd, char *str, int *ret_value)
|
||||
{
|
||||
if (!str)
|
||||
*ret_value += write(fd, "(null)", 6);
|
||||
else
|
||||
*ret_value += write(fd, str, ft_strlen(str));
|
||||
}
|
||||
27
str/ft_strcpy.c
Normal file
27
str/ft_strcpy.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/31 16:14:10 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/31 16:15:46 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strcpy(char *dst, const char *src)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (src[i])
|
||||
{
|
||||
dst[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
dst[i] = '\0';
|
||||
return (dst);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue