ft_strchr, norming ft_strcpy, ft_strncat, ft_strncpy
This commit is contained in:
parent
727ec54307
commit
698a37b399
3
Makefile
3
Makefile
@ -6,7 +6,7 @@
|
|||||||
# By: tmaze <marvin@42.fr> +#+ +:+ +#+ #
|
# By: tmaze <marvin@42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2018/04/04 10:51:59 by tmaze #+# #+# #
|
# Created: 2018/04/04 10:51:59 by tmaze #+# #+# #
|
||||||
# Updated: 2018/04/04 18:34:41 by tmaze ### ########.fr #
|
# Updated: 2018/04/04 18:59:36 by tmaze ### ########.fr #
|
||||||
# #
|
# #
|
||||||
#******************************************************************************#
|
#******************************************************************************#
|
||||||
|
|
||||||
@ -23,6 +23,7 @@ SRCS = \
|
|||||||
ft_strncpy.c \
|
ft_strncpy.c \
|
||||||
ft_strcat.c \
|
ft_strcat.c \
|
||||||
ft_strncat.c \
|
ft_strncat.c \
|
||||||
|
ft_strchr.c \
|
||||||
ft_isalpha.c \
|
ft_isalpha.c \
|
||||||
ft_isdigit.c \
|
ft_isdigit.c \
|
||||||
ft_isalnum.c \
|
ft_isalnum.c \
|
||||||
|
24
ft_strchr.c
Normal file
24
ft_strchr.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strchr.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2018/04/04 18:54:17 by tmaze #+# #+# */
|
||||||
|
/* Updated: 2018/04/04 19:15:12 by tmaze ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
char *ft_strchr(const char *s, int c)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = -1;
|
||||||
|
while (++i == 0 || s[i - 1])
|
||||||
|
if (s[i] == c)
|
||||||
|
return (strdup(&s[i]));
|
||||||
|
return (NULL);
|
||||||
|
}
|
@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/04/04 16:15:42 by tmaze #+# #+# */
|
/* Created: 2018/04/04 16:15:42 by tmaze #+# #+# */
|
||||||
/* Updated: 2018/04/04 16:39:29 by tmaze ### ########.fr */
|
/* Updated: 2018/04/04 19:19:41 by tmaze ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -21,4 +21,3 @@ char *ft_strcpy(char *dest, const char *src)
|
|||||||
dest[i] = src[i];
|
dest[i] = src[i];
|
||||||
return (dest);
|
return (dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/04/04 18:29:06 by tmaze #+# #+# */
|
/* Created: 2018/04/04 18:29:06 by tmaze #+# #+# */
|
||||||
/* Updated: 2018/04/04 18:34:17 by tmaze ### ########.fr */
|
/* Updated: 2018/04/04 19:20:04 by tmaze ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/04/04 16:55:29 by tmaze #+# #+# */
|
/* Created: 2018/04/04 16:55:29 by tmaze #+# #+# */
|
||||||
/* Updated: 2018/04/04 17:14:03 by tmaze ### ########.fr */
|
/* Updated: 2018/04/04 19:21:06 by tmaze ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -17,10 +17,9 @@ char *ft_strncpy(char *dest, const char *src, size_t n)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
i = -1;
|
i = -1;
|
||||||
while (++i < n && ( i == 0 || src[i - 1]))
|
while (++i < n && (i == 0 || src[i - 1]))
|
||||||
dest[i] = src[i];
|
dest[i] = src[i];
|
||||||
while (++i < n)
|
while (++i < n)
|
||||||
dest[i] = '\0';
|
dest[i] = '\0';
|
||||||
return (dest);
|
return (dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user