Skip to content

Commit

Permalink
lHamdulillah, Done, I guess
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza Talhaoui committed Nov 19, 2023
1 parent c9055c7 commit 0f39cca
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ ft_isalnum.c ft_memmove.c ft_striteri.c ft_strtrim.c ft_isalpha.c ft_memset.c ft
ft_substr.c ft_isascii.c ft_putchar_fd.c ft_strlcat.c ft_tolower.c ft_isdigit.c \
ft_putendl_fd.c ft_strlcpy.c ft_toupper.c ft_isprint.c ft_putnbr_fd.c ft_strlen.c

# BSRCS +=

OBJS=$(SRCS:.c=.o)
$(NAME): $(OBJS)
ar -rc $(NAME) $(OBJS)
Expand Down
6 changes: 6 additions & 0 deletions ft_atoi.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ int ft_atoi(char const *nptr)
else if (nptr[i] == '+')
i++;
while (nptr[i] >= '0' && nptr[i] <= '9')
{
if (r < 0 && s < 0)
return (0);
else if (r < 0 && s > 0)
return (-1);
r = r * 10 + nptr[i++] - '0';
}
return (r * s);
}
10 changes: 10 additions & 0 deletions ft_memchr.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ void *ft_memchr(const void *s, int c, size_t n)
}
return (NULL);
}

// int main() {
// char* p1 = "a";
// char* p2 = "a";

// printf("[%p]\n", memchr(p1, 'a', 1));
// printf("*************************\n");
// printf("[%p]\n", ft_memchr(p1, 'a', 1));
// return(0);
// }
12 changes: 9 additions & 3 deletions libft.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# include <unistd.h>
# include <stdlib.h>
# include <stdio.h>
# include <string.h>

int ft_isalpha(int c);
int ft_isdigit(int c);
Expand All @@ -26,6 +27,7 @@ int ft_tolower(int c);
int ft_atoi(char const *nptr);
int ft_memcmp(const void *s1, const void *s2, size_t n);
int ft_strncmp(char const *s1, char const *s2, size_t n);

char *ft_itoa(int n);
char *ft_strdup(char const *src);
char *ft_strchr(char const *s, int c);
Expand All @@ -35,18 +37,22 @@ char *ft_strtrim(char const *s1, char const *set);
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
char *ft_substr(char const *s, unsigned int start, size_t len);
char *ft_strnstr(char const *haystack, char const *needle, size_t n);

char **ft_split(char const *s, char c);

void ft_bzero(void *s, size_t n);
void ft_putnbr_fd(int n, int fd);
void ft_putchar_fd(char c, int fd);
void ft_putstr_fd(char *s, int fd);
void ft_putchar_fd(char c, int fd);
void ft_putendl_fd(char *s, int fd);
void ft_bzero(void *s, size_t n);
void ft_striteri(char *s, void (*f)(unsigned int, char*));

void *ft_memset(void *s, int c, 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_striteri(char *s, void (*f)(unsigned int, char*));

size_t ft_strlen(char const *str);
size_t ft_strlcat(char *dest, char const *src, size_t size);
size_t ft_strlcpy(char *dest, char const *src, size_t size);
Expand Down

0 comments on commit 0f39cca

Please sign in to comment.