protected strchr & strlen
This commit is contained in:
parent
c5a13918c2
commit
491de12723
4
Makefile
4
Makefile
@ -6,7 +6,7 @@
|
|||||||
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
|
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
|
||||||
# Updated: 2018/05/16 12:22:34 by tmaze ### ########.fr #
|
# Updated: 2018/05/16 15:07:10 by tmaze ### ########.fr #
|
||||||
# #
|
# #
|
||||||
#******************************************************************************#
|
#******************************************************************************#
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ $(NAME): $(OBJS)
|
|||||||
ar rcs $(NAME) $(OBJS)
|
ar rcs $(NAME) $(OBJS)
|
||||||
|
|
||||||
%.o: %.c libft.h
|
%.o: %.c libft.h
|
||||||
$(CC) $(CCFLAGS) $(CCSTD) $(INCLS) -c $< -o $@
|
$(CC) $(CCFLAGS) $(CCSTD) $(INCLS) -g -c $< -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS)
|
rm -f $(OBJS)
|
||||||
|
15
ft_strchr.c
15
ft_strchr.c
@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/04/04 18:54:17 by tmaze #+# #+# */
|
/* Created: 2018/04/04 18:54:17 by tmaze #+# #+# */
|
||||||
/* Updated: 2018/04/05 11:05:16 by tmaze ### ########.fr */
|
/* Updated: 2018/05/16 15:09:08 by tmaze ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -17,10 +17,13 @@ char *ft_strchr(const char *s, int c)
|
|||||||
int i;
|
int i;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
i = -1;
|
if (s != NULL)
|
||||||
tmp = (char*)s;
|
{
|
||||||
while (++i == 0 || tmp[i - 1])
|
i = -1;
|
||||||
if (tmp[i] == c)
|
tmp = (char*)s;
|
||||||
return (&tmp[i]);
|
while (++i == 0 || tmp[i - 1])
|
||||||
|
if (tmp[i] == c)
|
||||||
|
return (&tmp[i]);
|
||||||
|
}
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/04/03 15:33:37 by tmaze #+# #+# */
|
/* Created: 2018/04/03 15:33:37 by tmaze #+# #+# */
|
||||||
/* Updated: 2018/04/04 14:39:59 by tmaze ### ########.fr */
|
/* Updated: 2018/05/16 15:33:46 by tmaze ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ size_t ft_strlen(const char *s)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (s[i])
|
while (s != NULL && s[i])
|
||||||
i++;
|
i++;
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user