Fix for "0" input to be recognized as valid int
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 25 Apr 2024 09:17:47 +0000 (11:17 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 25 Apr 2024 09:17:47 +0000 (11:17 +0200)
ft_check/ft_isint.c

index acffdee2334004900e454664c84bc3b443bd0c4f..09afa3afb8b4ce88f12e5c765f7d3f5111ba9048 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/04/10 12:44:56 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/04/10 13:17:33 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/04/25 10:26:24 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -34,7 +34,7 @@ int   ft_isint(const char *str)
                        sign *= -1;
                ++str;
        }
-       while (*str == '0')
+       while (*str == '0' && *(str + 1))
                ++str;
        if (sign == -1)
                res = !ft_strcmp(str, newstr + 1);