From b1928f3e3d46e24c617fa09fa9d3e6c87e254bd9 Mon Sep 17 00:00:00 2001 From: Marc Agen Date: Wed, 23 Oct 2024 15:56:07 +0200 Subject: [PATCH 1/2] add: adding my_put_nbr.c --- src/handler/my_put_nbr.c | 22 ++++++++++++++++++++++ src/handler/point | Bin 0 -> 16168 bytes src/handler/point_hexa.c | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/handler/my_put_nbr.c create mode 100755 src/handler/point diff --git a/src/handler/my_put_nbr.c b/src/handler/my_put_nbr.c new file mode 100644 index 0000000..06d6f71 --- /dev/null +++ b/src/handler/my_put_nbr.c @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2024 +** my_put_nbr +** File description: +** display the number given as parameter +*/ +#include "../include/libmy.h" + +int my_put_nbr(int nb) +{ + if (nb < 0) { + my_putchar('-'); + nb *= -1; + } + if (nb < 10) { + my_putchar(nb + '0'); + } else { + my_put_nbr(nb / 10); + my_putchar(nb % 10 +'0'); + } + return 0; +} diff --git a/src/handler/point b/src/handler/point new file mode 100755 index 0000000000000000000000000000000000000000..8948ac287efdf6035e7a685cd3a01f93a83347e6 GIT binary patch literal 16168 zcmeHOU2GKB6~1c>m|*Y%CILh7CJj*t^A~|e1g*~@w`CklwUC+Qp7$<8Gw-3C>FqH zrC25AfLts&r4K0ptx8vlreX>4vjEX=8D^%zm5LUO+(Jb3n<))rgCH>q>IeGGMg_@k zTu$v^WW8Nq0G%NPk{#f`nq+AXjLMf%Jo+DZmh4WuM1|=!CF}}wkrS^&Z*`d z?E;D!MvlTLiViE8%R^l`>Cyh9XPbX~zwoL3{^max-?+N=Hy>0yI*K;fZuCJLOjsUI z5tK2HV}~{>9$$i-;t($x?GKy=ZQ2+18-f2J7rxZE%B~UtcHmmbUGB)W{g!@vLcN+O{_&(kY`Y z(vdKritc1OMV0ExbXr3kF&~U#F{tshoj#{@|kbG z4#Qm}_JfRxzfbr+KDsS`CmGCydOA?I(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X%1(YRy4T?Vi?}z!eETnk;e1pn4 zMe|wy2L{UPWY6=H?eTmE);pi-y-bR`z+*ez_CEN+46w5UR{;NnL*{Hf@QaJ!SHpFG zi9MYevnH5^9qy5ixNb(e1rS*?*VPs56qCE*bu+1V;(qunSVq%&cOu;pN$62CoyqEv zT(9U%CwmfxX+(q7(_7#M{kR^?o8w_1uDOStp|L zY)=BBAUkDbWVh(lf^8+s)3H2t=m5%_dICX@X485sl8VCVgvo%w$%LKY5RIqwT-Jy} zlTz@ZcVx3v3>}z&!wnoUJoPZ`QHH6 zbkJptLXhVSirt+6X#l!ZMuc^B~|FlKpwz$VgxFbf#;v z9=87?_~V+CWnPyuhNv=k`-v9EAcHYwe_kgu4wIofe%$|Wlm9ld<8?Qq=I}=!cl^Ew z9L9vpw|{r&_lKWHs2JH+&Lf_H%jq8=KgJLmITHV@F}?{pr~iIZFtQyN!7}5Z%fE*d zjMeN&$bO7JarvJj1!J5C#^uk&zU}hobrT~$@3Fo6{y9(nb~ORAB*gW(Gr9eL1xkz` z`VLfA;6++|%pOT8Nhv*q`jr zI0u}a{vt%C)e5;DE`a@5#&@&Gas9l0^pn5a9_w + + + +void display_pointer_hexa(void *nb) +{ + void *result = nb; + + while (nb != 0) { + result = nb % 16; + if (result < 10) + my_putchar(result + 48); + else + my_putchar(result + 87); + nb /= 16; + } + +} + +int main(void) +{ + int a = 42; + char b = 'b'; + char c[] = "Hello World!"; + + display_pointer_hexa(&a); + printf("\n%p\n", &a); + display_pointer_hexa(&b); + printf("\n%p\n", &b); + display_pointer_hexa(&c); + printf("\n%p\n", &c); +} From ffce6927f5e39c7533bbbda92f84086264a5cb9e Mon Sep 17 00:00:00 2001 From: Marc Agen Date: Wed, 23 Oct 2024 16:02:35 +0200 Subject: [PATCH 2/2] add my_put_nbr --- src/handler/point | Bin 16168 -> 0 bytes src/handler/point_hexa.c | 39 --------------------------------------- 2 files changed, 39 deletions(-) delete mode 100755 src/handler/point delete mode 100644 src/handler/point_hexa.c diff --git a/src/handler/point b/src/handler/point deleted file mode 100755 index 8948ac287efdf6035e7a685cd3a01f93a83347e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16168 zcmeHOU2GKB6~1c>m|*Y%CILh7CJj*t^A~|e1g*~@w`CklwUC+Qp7$<8Gw-3C>FqH zrC25AfLts&r4K0ptx8vlreX>4vjEX=8D^%zm5LUO+(Jb3n<))rgCH>q>IeGGMg_@k zTu$v^WW8Nq0G%NPk{#f`nq+AXjLMf%Jo+DZmh4WuM1|=!CF}}wkrS^&Z*`d z?E;D!MvlTLiViE8%R^l`>Cyh9XPbX~zwoL3{^max-?+N=Hy>0yI*K;fZuCJLOjsUI z5tK2HV}~{>9$$i-;t($x?GKy=ZQ2+18-f2J7rxZE%B~UtcHmmbUGB)W{g!@vLcN+O{_&(kY`Y z(vdKritc1OMV0ExbXr3kF&~U#F{tshoj#{@|kbG z4#Qm}_JfRxzfbr+KDsS`CmGCydOA?I(Yd#&I%8`2zU|jBH%^9i+~paF9Kc!{-p@~ zt!&lbwf@^B+Q97Jt`kB#GHe!EqgwwjO3ul0tPNiW+FE@SKFcaY0_|g{xp~d9tghoy z#)ad}%abxL7;m1nWoz{}z`LugvQbEXYju-Le%>Y5Pmyc>)RMpSIW2!p>%Ts>t1VnJ zTys%7wxt!SwU#ac(+|3WWtCsSRtexY0izw8U5l`3+*}G>`!J}wHqW|RR(Tlh&JlwB zJZZn72w}|wEkCA>{P_iKWPFz9yP#cqV3tDx=c#}a>#FJp`(ytPZ$Y)lt!>x(x4eN_ zEq}u-)dsfw0EEK52bNWcLNqSSJ_)k#v*2sjkN!6gf)X?B;0J>d(DH{0+CaE4AoAgf zTl-|zpC26=uN*0?^quX$R<`DBzI~$q(8Rn~7Y~Fd`iHB_emyIZiyj%dZCir_i8ru6*@{@A>NB`p#c0D+DMO z`kNLmd$DZ(!IHz`g^EqjtbbCz2E=l)-a)YAcV=jgyb0H7;H#0KgmoQ->n*77%gBWn z`oCJ#u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Gr9eL1xkz` z`VLfA;6++|%pOT8Nhv*q`jr zI0u}a{vt%C)e5;DE`a@5#&@&Gas9l0^pn5a9_w - - - -void display_pointer_hexa(void *nb) -{ - void *result = nb; - - while (nb != 0) { - result = nb % 16; - if (result < 10) - my_putchar(result + 48); - else - my_putchar(result + 87); - nb /= 16; - } - -} - -int main(void) -{ - int a = 42; - char b = 'b'; - char c[] = "Hello World!"; - - display_pointer_hexa(&a); - printf("\n%p\n", &a); - display_pointer_hexa(&b); - printf("\n%p\n", &b); - display_pointer_hexa(&c); - printf("\n%p\n", &c); -}