added the ft_str_is_numeric() function
This commit is contained in:
		
							parent
							
								
									a31f44d552
								
							
						
					
					
						commit
						a5c0814aa3
					
				| @ -1,12 +1,12 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   utils.c                                            :+:      :+:    :+:   */ | ||||
| /*   ft_utils.c                                         :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: achubuko <marvin@42.fr>                    +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2023/12/02 21:56:30 by achubuko          #+#    #+#             */ | ||||
| /*   Updated: 2023/12/02 23:45:23 by achubuko         ###   ########.fr       */ | ||||
| /*   Updated: 2023/12/03 18:03:15 by asargsya         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
| #include "ft_utils.h" | ||||
| @ -25,3 +25,20 @@ size_t	ft_strlen(char *s) | ||||
| 		l++; | ||||
| 	return (l); | ||||
| } | ||||
| int ft_str_is_numeric(char *str) | ||||
| { | ||||
| 	int i; | ||||
| 
 | ||||
| 	i = 0; | ||||
| 	if (str[i] == '\0') | ||||
| 		return (0); | ||||
| 	while (str[i] != '\0') | ||||
| 	{ | ||||
| 		if (str[i] < '0' || str[i] > '9') | ||||
| 			return (0); | ||||
| 		i++; | ||||
| 	} | ||||
| 	if (str[0] == '-') | ||||
| 		return (-1); | ||||
| 	return (1); | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user