From 3c90d29fe5bf9ba6da090cd59c8c139d269f8bd4 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Sun, 10 Mar 2024 13:35:18 +0100 Subject: [PATCH] Add everything --- ft_atoi.o | Bin 0 -> 892 bytes ft_isalpha.o | Bin 0 -> 700 bytes ft_itoa.c | 68 ++++++++++++++++++++++++++++++++ ft_putnbr_fd.c | 38 ++++++++++++++++++ ft_split.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ ft_striteri.c | 25 ++++++++++++ ft_strjoin.c | 64 ++++++++++++++++++++++++++++++ ft_strmapi.c | 46 ++++++++++++++++++++++ ft_strtrim.c | 63 ++++++++++++++++++++++++++++++ ft_substr.c | 47 ++++++++++++++++++++++ 10 files changed, 455 insertions(+) create mode 100644 ft_atoi.o create mode 100644 ft_isalpha.o create mode 100644 ft_itoa.c create mode 100644 ft_putnbr_fd.c create mode 100644 ft_split.c create mode 100644 ft_striteri.c create mode 100644 ft_strjoin.c create mode 100644 ft_strmapi.c create mode 100644 ft_strtrim.c create mode 100644 ft_substr.c diff --git a/ft_atoi.o b/ft_atoi.o new file mode 100644 index 0000000000000000000000000000000000000000..8280d24274dbed5556b69d10fb25b13f25e0d5a4 GIT binary patch literal 892 zcmX^A>+L^w1_nlE1|R{%EI_;i#83cYAdm!N3lJX%Xn@MyfYLBN&`bsp2AK;2@$n_8 z6(tZhgdgG>5rW{uSh7gwf!qQIEDQ~BHjoh?pPZjtkeFN&Uz%5*nU@kD@8g0juK+bi z0V?=|3F4Lrpo5@NKoJCpk5A2rPb*5yO@)ZX$D_K>0jkLXszm~54$N;LA#MhS45$>C zG6IqkKn&K#&&9w7#2^5&6eOMibw>e^<^l47`WXU%7#V={Lajv>CW;;E(fQP)v-Zbv z*Eb*|j=O#VX*=%v0YrIpyZ-P<_Wi)WPlTiS7bky@42B@D!!|~Tj?&lsec~8$3J&~J zj)5e*TwkwXbp7yh*8l(iQEk!XZxsM40lEh$^&g=UD8^uT zz@yt2=%P@di%bNY{~2_+zT)q}wAj*te;&x%K2A!^7 z5Z25DTl$56z3ZFU!yr4M0Gi$~f>{JA&sY`2z*r%`D8R$cF#)Jb1t<;*tp)!;-uV9? lmR=bg`2^aSoO#)x`al#=IUC4eeq__*(@NqKOY$>;;s7J@rQZMm literal 0 HcmV?d00001 diff --git a/ft_isalpha.o b/ft_isalpha.o new file mode 100644 index 0000000000000000000000000000000000000000..b75a8daff9abb7555666f847081be7b56bcc4024 GIT binary patch literal 700 zcmX^A>+L^w1_nlE1|R{%EI_;i#83cYAdm!N3lJX%H~)KfXoBA1rAsk8sKaoBR)PkKer$;xg@?cuRJp^B|hHA1zA1; z%29yQ7EBPg%mC6*rvh0B5FekK5ua9+n41a_i;qWjUjtOB1C)+{ng``Fa5FGuz}O(# z2#6(s7;G0m7Xup*g8;}mQKqFG0}=WCKZ{{y(vYK@2#6 z#utV&MW8AetAZF9D+Cw?c-T2609B~~#btmv;Xeex;+w&dPoRy-nU@W2GT85IAcOgl QO^?qkPRuFDNCb)l0OrzDLI3~& literal 0 HcmV?d00001 diff --git a/ft_itoa.c b/ft_itoa.c new file mode 100644 index 0000000..401ba6a --- /dev/null +++ b/ft_itoa.c @@ -0,0 +1,68 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_itoa.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser */ +/* int main() { */ +/* char* itoa = ft_itoa(0); */ +/* printf("%s\n", itoa); */ +/* } */ diff --git a/ft_putnbr_fd.c b/ft_putnbr_fd.c new file mode 100644 index 0000000..96f5f4b --- /dev/null +++ b/ft_putnbr_fd.c @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser 9) + putnbr_fd_rec(n / 10, fd); + write(fd, &c, 1); +} + +void ft_putnbr_fd(int n, int fd) +{ + if (n == -2147483648) + { + write(fd, "-2147483648", 11); + return ; + } + if (n < 0) + { + write(fd, "-", 1); + n *= -1; + } + putnbr_fd_rec(n, fd); +} diff --git a/ft_split.c b/ft_split.c new file mode 100644 index 0000000..e9ba9f9 --- /dev/null +++ b/ft_split.c @@ -0,0 +1,104 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_split.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser */ +/* int main() */ +/* { */ +/* char s[] = " split this for me !"; */ +/* char **split = ft_split(s, ' '); */ + +/* if (split) { */ +/* while(*split) { */ +/* printf("%s\n", *split); */ +/* split++; */ +/* } */ +/* } */ +/* } */ diff --git a/ft_striteri.c b/ft_striteri.c new file mode 100644 index 0000000..e7c8b89 --- /dev/null +++ b/ft_striteri.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_striteri.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser + +static int get_len(char const *s) +{ + int i; + + i = 0; + while (s[i]) + i++; + return (i); +} + +static int copy_str(char *dst, const char *src) +{ + int i; + + i = 0; + while (src[i]) + { + dst[i] = src[i]; + i++; + } + return (i); +} + +char *ft_strjoin(char const *s1, char const *s2) +{ + int len; + char *result; + + len = get_len(s1) + get_len(s2); + result = malloc(len + 1); + if (result) + { + result[len] = '\0'; + len = copy_str(result, s1); + len = copy_str(result + len, s2); + return (result); + } + else + return (0); +} + +/* #include */ + +/* int main(void) */ +/* { */ +/* char s1[] = "Hello "; */ +/* char s2[] = "World"; */ + +/* printf("%s\n", ft_strjoin(s1, s2)); */ +/* } */ diff --git a/ft_strmapi.c b/ft_strmapi.c new file mode 100644 index 0000000..5d31408 --- /dev/null +++ b/ft_strmapi.c @@ -0,0 +1,46 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strmapi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser */ +/* int main(){ */ +/* char str[] = "AAAAAAAA"; */ +/* printf("%s\n", ft_strmapi(str, func)); */ +/* } */ diff --git a/ft_strtrim.c b/ft_strtrim.c new file mode 100644 index 0000000..933987b --- /dev/null +++ b/ft_strtrim.c @@ -0,0 +1,63 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strtrim.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser + +static int is_in(char c, const char *str) +{ + while (*str) + { + if (c == *str) + return (1); + else + str++; + } + return (0); +} + +char *ft_strtrim(char const *s1, char const *set) +{ + int i; + char *start; + char *end; + char *result; + + start = (char *)s1; + while (is_in(*start, set)) + start++; + i = 0; + while (s1[i]) + i++; + end = (char *)s1 + i - 1; + while (end > start && is_in(*end, set)) + end--; + i = end - start + 1; + result = malloc(i + 1); + if (result) + { + result[i] = '\0'; + i = 0; + while (start <= end) + result[i++] = *(start++); + return (result); + } + return (0); +} + +/* #include */ + +/* int main(void) */ +/* { */ +/* char s1[] = " \t \t \t "; */ + +/* printf("%s\n", ft_strtrim(s1, " \t")); */ +/* } */ diff --git a/ft_substr.c b/ft_substr.c new file mode 100644 index 0000000..f5ee2aa --- /dev/null +++ b/ft_substr.c @@ -0,0 +1,47 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_substr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser + +char *ft_substr(char const *s, unsigned int start, size_t len) +{ + size_t i; + char *result; + + i = 0; + while (s[i]) + i++; + if (i - start < len) + len = (i - start); + if (start >= len) + len = 0; + result = malloc(len + 1); + if (result) + { + result[len] = '\0'; + i = 0; + while (i < len) + { + result[i] = s[i + start]; + i++; + } + } + return (result); +} + +/* #include */ +/* int main () */ +/* { */ +/* char s[] = "Hello there"; */ +/* char *substr = ft_substr(s, 25, 10); */ +/* printf("%s\n", substr); */ +/* } */ -- 2.47.2