Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_putstr.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/18 17:44:59 by sboucher #+# #+# */
- /* Updated: 2017/07/18 17:45:40 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- void ft_putchar(char c);
- void ft_putstr(char *str)
- {
- int i;
- i = 0;
- while (str[i] != '\0')
- {
- ft_putchar(str[i]);
- i++;
- }
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_putnbr.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/12 11:57:02 by sboucher #+# #+# */
- /* Updated: 2017/07/12 19:52:09 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- void ft_putchar(char c);
- void ft_putnbr(int nb)
- {
- unsigned int n;
- n = nb;
- if (nb < 0)
- {
- n = n * -1;
- ft_putchar('-');
- }
- if (n / 10 > 0)
- {
- ft_putnbr(n / 10);
- }
- ft_putchar(n % 10 + '0');
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_atoi.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/09 12:56:41 by sboucher #+# #+# */
- /* Updated: 2017/07/12 23:16:32 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- int ft_atoi(char *str)
- {
- int i;
- int ent;
- int neg;
- neg = 1;
- ent = 0;
- i = 0;
- while ((str[i] >= 9 && str[i] <= 13) || str[i] == 32)
- i++;
- if (str[i] == '-' || str[i] == '+')
- {
- if (str[i] == '-')
- neg = -1;
- i++;
- }
- while (str[i] >= '0' && str[i] <= '9')
- {
- ent = ent * 10 + str[i] - 48;
- i++;
- }
- return (ent * neg);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strcpy.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/12 23:20:34 by sboucher #+# #+# */
- /* Updated: 2017/07/18 17:46:28 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- char *ft_strcpy(char *dest, char *src)
- {
- int i;
- i = 0;
- while (src[i] != '\0')
- {
- dest[i] = src[i];
- i++;
- }
- dest[i] = src[i];
- return (dest);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strncpy.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/13 10:30:53 by sboucher #+# #+# */
- /* Updated: 2017/07/13 14:20:40 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- char *ft_strncpy(char *dest, char *src, unsigned int n)
- {
- unsigned int i;
- i = 0;
- while (src[i] != '\0' && n > i)
- {
- dest[i] = src[i];
- i++;
- }
- while (n > i)
- {
- dest[i] = '\0';
- i++;
- }
- return (dest);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strstr.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/13 17:31:50 by sboucher #+# #+# */
- /* Updated: 2017/07/17 02:00:11 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- char *ft_strstr(char *str, char *to_find)
- {
- int taille_str;
- int taille_to;
- int m;
- taille_str = 0;
- taille_to = 0;
- while (str[taille_str] != '\0')
- {
- m = taille_str;
- while (to_find[taille_to] != '\0' && str[m] == to_find[taille_to])
- {
- if (to_find[taille_to + 1] == '\0')
- return (&str[taille_str]);
- taille_to++;
- m++;
- }
- taille_to = 0;
- taille_str++;
- }
- return (0);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strcmp.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/17 11:09:24 by sboucher #+# #+# */
- /* Updated: 2017/07/17 14:36:15 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- int ft_strcmp(char *s1, char *s2)
- {
- int i;
- i = 0;
- while (s1[i] || s2[i])
- {
- if (s1[i] == s2[i])
- i++;
- if (s1[i] != s2[i])
- {
- if (s1[i] < s2[i])
- return (s1[i] - s2[i]);
- if (s1[i] > s2[i])
- return (s1[i] - s2[i]);
- }
- }
- return (0);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strncmp.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/17 13:38:39 by sboucher #+# #+# */
- /* Updated: 2017/07/18 20:10:20 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- int ft_strncmp(char *s1, char *s2, unsigned int n)
- {
- unsigned int i;
- i = 0;
- while (s1[i] != '\0' && s2[i] != '\0' && s1[i] == s2[i] && n > i)
- i++;
- return (s1[i] - s2[i]);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strupcase.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/17 14:42:37 by sboucher #+# #+# */
- /* Updated: 2017/07/17 15:35:40 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- char *ft_strupcase(char *str)
- {
- int i;
- i = 0;
- while (str[i] != '\0')
- {
- if (str[i] >= 'a' && str[i] <= 'z')
- str[i] = str[i] + ('A' - 'a');
- i++;
- }
- return (str);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strlowcase.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/17 15:38:46 by sboucher #+# #+# */
- /* Updated: 2017/07/17 15:50:37 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- char *ft_strlowcase(char *str)
- {
- int i;
- i = 0;
- while (str[i] != '\0')
- {
- if (str[i] >= 'A' && str[i] <= 'Z')
- str[i] = str[i] - ('A' - 'a');
- i++;
- }
- return (str);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strcapitalize.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/17 17:29:12 by sboucher #+# #+# */
- /* Updated: 2017/07/17 21:47:31 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- char *ft_strcapitalize(char *str)
- {
- int i;
- i = 0;
- if (str[i] >= 'a' && str[i] <= 'z')
- str[i] = str[i] + ('A' - 'a');
- while (str[i] != '\0')
- {
- if ((str[i] >= 'A' && str[i] <= 'Z') ||
- (str[i] >= 'a' && str[i] <= 'z') ||
- (str[i] >= '0' && str[i] <= '9'))
- {
- if (str[i + 1] >= 'A' && str[i + 1] <= 'Z')
- str[i + 1] = str[i + 1] + 32;
- }
- else
- {
- if (str[i + 1] >= 'a' && str[i + 1] <= 'z')
- str[i + 1] = str[i + 1] - 32;
- }
- i++;
- }
- return (str);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_str_is_alpha.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/17 23:10:12 by sboucher #+# #+# */
- /* Updated: 2017/07/17 23:44:30 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- int ft_str_is_alpha(char *str)
- {
- int i;
- i = 0;
- while (str[i] != '\0')
- {
- if (str[i] < 'A' || str[i] > 'z')
- return (0);
- i++;
- }
- return (1);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_str_is_numeric.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/17 23:51:37 by sboucher #+# #+# */
- /* Updated: 2017/07/18 00:07:17 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- int ft_str_is_numeric(char *str)
- {
- int i;
- i = 0;
- while (str[i] != '\0')
- {
- if (str[i] < '0' || str[i] > '9')
- return (0);
- i++;
- }
- return (1);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_str_is_lowercase.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/17 23:56:09 by sboucher #+# #+# */
- /* Updated: 2017/07/18 18:10:55 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- int ft_str_is_lowercase(char *str)
- {
- int i;
- i = 0;
- while (str[i] != '\0')
- {
- if (str[i] < 'a' || str[i] > 'z')
- return (0);
- i++;
- }
- return (1);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_str_is_uppercase.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/18 00:22:27 by sboucher #+# #+# */
- /* Updated: 2017/07/18 00:22:37 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- int ft_str_is_uppercase(char *str)
- {
- int i;
- i = 0;
- while (str[i] != '\0')
- {
- if (str[i] < 'A' || str[i] > 'Z')
- return (0);
- i++;
- }
- return (1);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_str_is_printable.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/18 00:24:19 by sboucher #+# #+# */
- /* Updated: 2017/07/18 00:46:05 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- int ft_str_is_printable(char *str)
- {
- int i;
- i = 0;
- while (str[i] != '\0')
- {
- if (str[i] < ' ' || str[i] > '~')
- return (0);
- i++;
- }
- return (1);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strcat.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/18 00:57:12 by sboucher #+# #+# */
- /* Updated: 2017/07/18 01:34:42 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- char *ft_strcat(char *dest, char *src)
- {
- int i;
- int k;
- i = 0;
- k = 0;
- while (dest[i] != '\0')
- i++;
- while (src[k])
- {
- dest[i + k] = src[k];
- k++;
- }
- dest[i + k] = '\0';
- return (dest);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_strncat.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: sboucher <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/07/18 01:45:04 by sboucher #+# #+# */
- /* Updated: 2017/07/18 02:09:27 by sboucher ### ########.fr */
- /* */
- /* ************************************************************************** */
- char *ft_strncat(char *dest, char *src, int nb)
- {
- int i;
- int k;
- i = 0;
- k = 0;
- while (dest[i] != '\0')
- i++;
- while (src[k] && nb > k)
- {
- dest[i + k] = src[k];
- k++;
- }
- dest[i + k] = '\0';
- return (dest);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement