Skip to content

Commit

Permalink
bonus working and fixed prototypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marília Passos committed May 15, 2023
1 parent c4a979f commit 6d662f6
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ PART2 = ft_itoa.c ft_strjoin.c ft_split.c ft_striteri.c ft_strmapi.c \
ft_substr.c ft_strtrim.c ft_putchar_fd.c ft_putstr_fd.c ft_putendl_fd.c \
ft_putnbr_fd.c

BONUS = ft_lstnew.c ft_lstadd_front.c ft_lstsize.c ft_lstlast.c ft_lstadd_back.c \
ft_lstdelone.c ft_lstclear.c ft_lstiter.c ft_lstmap.c
BONUS = ft_lstnew_bonus.c ft_lstadd_front_bonus.c ft_lstsize_bonus.c ft_lstlast_bonus.c ft_lstadd_back_bonus.c \
ft_lstdelone_bonus.c ft_lstclear_bonus.c ft_lstiter_bonus.c ft_lstmap_bonus.c

SRC = ${PART1} ${PART2}

Expand Down
12 changes: 6 additions & 6 deletions lib/ft_atoi.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//ft_isdigit(str[i]) returns boolean if is digit or not.
#include "libft.h"

int ft_atoi(const char *str)
int ft_atoi(const char *nptr)
{
int i;
int sign;
Expand All @@ -23,19 +23,19 @@ int ft_atoi(const char *str)
i = 0;
sign = 1;
result = 0;
while (str[i] == 32 || (str[i] >= 9 && str[i] <= 13))
while (nptr[i] == 32 || (nptr[i] >= 9 && nptr[i] <= 13))
i++;
if (str[i] == '-')
if (nptr[i] == '-')
{
sign = -1;
i++;
}
else if (str[i] == '+')
else if (nptr[i] == '+')
i++;
while (ft_isdigit(str[i]))
while (ft_isdigit(nptr[i]))
{
result *= 10;
result += str[i] - '0';
result += nptr[i] - '0';
i++;
}
return (result * sign);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions lib/ft_strlcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// :space had been available.
#include "libft.h"

size_t ft_strlcat(char *dest, const char *src, size_t size)
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
size_t i;
size_t len_src;
Expand All @@ -32,18 +32,18 @@ size_t ft_strlcat(char *dest, const char *src, size_t size)
i = 0;
str_result = 0;
len_src = ft_strlen(src);
len_dest = ft_strlen(dest);
len_dest = ft_strlen(dst);
if (size > len_dest)
str_result = len_src + len_dest;
else
return (len_src + size);
while (src[i] && (len_dest + 1) < size)
{
dest[len_dest] = src[i];
dst[len_dest] = src[i];
len_dest++;
i++;
}
dest[len_dest] = '\0';
dst[len_dest] = '\0';
return (str_result);
}
// int main(void)
Expand Down
8 changes: 4 additions & 4 deletions lib/ft_strlcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@

/* The ft_strlcpy function copies up to dst size - 1 (we remove 1 because
* of the null-terminator)characters from the string src to dst,
* NUL-terminating the result if dstsize is not 0.
* NUL-terminating the result if size is not 0.
* It ensures that the resulting string will always be NUL-terminated.
* The size of the source string is returned.
* Return the size of the source string
*/
#include "libft.h"

size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
size_t ft_strlcpy(char *dst, const char *src, size_t size)
{
size_t i;

i = 0;
if (dstsize > 0)
if (size > 0)
{
while (src[i] && i < dstsize - 1)
while (src[i] && i < size - 1)
{
dst[i] = src[i];
i++;
Expand Down

0 comments on commit 6d662f6

Please sign in to comment.