Open mysthair opened 8 years ago
I contest
>>>> 01_part2_ft_strsub.spec.c --- [FAIL] F.. [FAIL] test1 -> ft_strsub(str, 0, (size_t)-10) == ((void*)0) could you try this code plz:
>>>> 01_part2_ft_strsub.spec.c --- [FAIL] F.. [FAIL] test1 -> ft_strsub(str, 0, (size_t)-10) == ((void*)0)
/* ** / / / / ::: :::::::: / / ft_strsub.c :+: :+: :+: / / +:+ +:+ +:+ / / By: jleblanc jleblanc@student.42.fr +#+ +:+ +#+ / / +#+#+#+#+#+ +#+ / / Created: 2016/11/15 23:02:50 by jleblanc #+# #+# / / Updated: 2016/11/23 18:29:17 by jleblanc ### ########.fr / / / / ** */
char ft_strsub(const char s, unsigned int start, size_t len) { char *dst; size_t slen;
slen = ft_strlen(s); if (start >= slen) return (ft_strdup("")); if (start + len > slen) len = slen - start; if ((dst = ft_strnew(len))) ft_strncpy(dst, s + start, len); return (dst);
}
/* ** / / / / ::: :::::::: / / test_ft_strsub.c :+: :+: :+: / / +:+ +:+ +:+ / / By: jleblanc jleblanc@student.42.fr +#+ +:+ +#+ / / +#+#+#+#+#+ +#+ / / Created: 2016/11/24 19:42:01 by jleblanc #+# #+# / / Updated: 2016/11/24 19:50:39 by jleblanc ### ########.fr / / / / ** */
int main() { char *str = "Je suis le meeilleuuuuuuur :P";
char *res = ft_strsub(str, 0, (size_t)-10); if (res == NULL) ft_putendl("ft_strsub(str, 0, (size_t)-10) return NULL !!!"); else { ft_putstr("ft_strsub(str, 0, (size_t)-10) return \""); ft_putstr(res); ft_putendl("\""); } return (0);
the result is :
➜ libft git:(master) ✗ gww test_ft_strsub.c libft.a ➜ libft git:(master) ✗ ./a.out ft_strsub(str, 0, (size_t)-10) return "Je suis le meeilleuuuuuuur :P"
I contest
>>>> 01_part2_ft_strsub.spec.c --- [FAIL] F.. [FAIL] test1 -> ft_strsub(str, 0, (size_t)-10) == ((void*)0)
could you try this code plz:/* ** / / / / ::: :::::::: / / ft_strsub.c :+: :+: :+: / / +:+ +:+ +:+ / / By: jleblanc jleblanc@student.42.fr +#+ +:+ +#+ / / +#+#+#+#+#+ +#+ / / Created: 2016/11/15 23:02:50 by jleblanc #+# #+# / / Updated: 2016/11/23 18:29:17 by jleblanc ### ########.fr / / / / ** */
include "libft.h"
char ft_strsub(const char s, unsigned int start, size_t len) { char *dst; size_t slen;
}
/* ** / / / / ::: :::::::: / / test_ft_strsub.c :+: :+: :+: / / +:+ +:+ +:+ / / By: jleblanc jleblanc@student.42.fr +#+ +:+ +#+ / / +#+#+#+#+#+ +#+ / / Created: 2016/11/24 19:42:01 by jleblanc #+# #+# / / Updated: 2016/11/24 19:50:39 by jleblanc ### ########.fr / / / / ** */
include "ft_strsub.c"
int main() { char *str = "Je suis le meeilleuuuuuuur :P";
}
the result is :
➜ libft git:(master) ✗ gww test_ft_strsub.c libft.a ➜ libft git:(master) ✗ ./a.out ft_strsub(str, 0, (size_t)-10) return "Je suis le meeilleuuuuuuur :P"