char *ft_itoa(int n) { char *s; int lenght; int signe; signe = ft_signe(n); if (!(s = ft_strnew(ft_lenght(n) + signe))) return (NULL); if (ft_signe(n) == 1) n = -n; lenght = ft_lenght(n) + signe; s[lenght] = '\0'; if (n == 0) s[0] = '0'; if (n == -2147483648) return (ft_strdup("-2147483648")); while (n != 0) { s[--lenght] = ((n % 10) + '0'); n /= 10; } if (signe == 1) s[--lenght] = '-'; return (s); }
char *ft_strjoin(char const *s1, char const *s2) { unsigned int i; unsigned int j; char *str; unsigned int len; len = ft_lenght(s1) + ft_lenght(s2) + 1; str = (char*)malloc(sizeof(char) * len); if (str == NULL) return (NULL); i = 0; j = 0; while (*(s1 + i) != '\0') { *(str + i) = *(s1 + i); i++; } while (*(s2 + j) != '\0') { *(str + i) = *(s2 + j); i++; j++; } *(str + i) = '\0'; return (str); }
int ft_istype_u(uintmax_t c, char *opt) { char *str; int b; int d; int i; str = ft_strdup(""); b = 0; i = 0; if (ft_flag_hh(opt) == 1) o_tochar_spe(c, "0123456789", &str, &i); else o_tochar(c, "0123456789", &str, &i); if (ft_accu(opt) > 0) i = ft_accu(opt) - ft_strlen(str); d = ft_lenght(opt) - ((i > 0) ? (i + ft_strlen(str)) : ft_strlen(str)); if (ft_accu(opt) == -9876) return (0); b += ft_opt_hub12(opt, d, c, str); b += ft_print_accu(i) + ft_strlen(str); if (ft_flag_hh(opt) == 1) ft_putnbr_spe_short(c); else ft_putnbr_spe_spe(c); b += ft_opt_hub2(opt, d); return (b); }
int ft_istype_o(uintmax_t c, char *opt) { char *str; int i; int b; int d; b = 0; i = 0; str = ft_istype_o_split(c, opt); if (ft_accu(opt) > 0) i = ft_accu(opt) - (ft_strlen(str) + ((ft_flag_dieze(opt) == 1 && c != 0) ? 1 : 0)); d = ft_lenght(opt) - ((i > 0) ? (i + ft_strlen(str)) : ft_strlen(str)); if (ft_accu(opt) == -9876 && ft_flag_dieze(opt) == 0) return (0); b += ft_opt_hub5(opt, d, c); b += ft_print_accu(i) + ft_strlen(str); if (ft_flag_dieze(opt) == 1 && c != 0) { b++; ft_putchar('0'); } ft_print_o(c, opt); b += ft_opt_hub4(opt, d); return (b); }
char *ft_itoa_base(int n, int base) { static char *num; char *str; int i; num = "0123456789abcdefghijklmnopqrstuvwxyz"; i = ft_lenght(n); i--; if (!(str = (char *)malloc(sizeof(char) * i + 1))) return (NULL); if (base < 2 || base > 35) { str[i] = '\0'; return (str); } if (n < 0) n = n * -1; while (n > 0) { str[i] = num[n % base]; n /= base; i--; } return (str); }
int ft_istype_percent(char *opt) { int i; i = ft_lenght(opt) - 1; i = ft_opt_hub3(opt, i) + 1; ft_putchar('%'); return (i); }
int ft_isnotype(char c, char *opt) { int i; int b; b = ft_lenght(opt) - 1; i = ft_opt_hub3(opt, b) + 1; ft_putchar(c); i += ft_opt_hub4(opt, b); return (i); }
char *ft_itoa_base(long long int nb, char *base) { int l; int sign; char *str; l = 0; sign = nb < 0 ? 1 : 0; nb = nb > 0 ? -nb : nb; if (nb == 0) return (ft_mal_char('0')); l = ft_lenght(ft_strlen(base), nb); str = (char*)malloc(sizeof(char) * (l + sign + 1)); str[l + sign] = '\0'; while (nb != 0) { str[--l + sign] = base[-(nb % (long long int)ft_strlen(base))]; nb = nb / (long long int)ft_strlen(base); } if (sign == 1) str[0] = '-'; return (str); }
int mid_putwstr(char *opt, int c) { c = ft_opt_hub3(opt, ft_lenght(opt)); c = ft_lenght(opt); return (c); }