From 936fa139c06e71e5a2c36a21d64eee808d77789b Mon Sep 17 00:00:00 2001 From: SavaletDev Date: Tue, 12 Dec 2023 14:12:17 +0100 Subject: [PATCH] Init --- .gitignore | 3 ++ Makefile | 34 +++++++++++++++++ include/radar.h | 16 ++++++++ lib/.gitignore | 1 + lib/my/.gitignore | 2 + lib/my/Makefile | 58 ++++++++++++++++++++++++++++ lib/my/lib.h | 60 +++++++++++++++++++++++++++++ lib/my/my_compute_power_rec.c | 20 ++++++++++ lib/my/my_compute_square_root.c | 19 +++++++++ lib/my/my_error.c | 14 +++++++ lib/my/my_format.c | 68 +++++++++++++++++++++++++++++++++ lib/my/my_isneg.c | 17 +++++++++ lib/my/my_printf.c | 30 +++++++++++++++ lib/my/my_put_address.c | 26 +++++++++++++ lib/my/my_put_float.c | 47 +++++++++++++++++++++++ lib/my/my_put_float_upper.c | 47 +++++++++++++++++++++++ lib/my/my_put_hexa.c | 24 ++++++++++++ lib/my/my_put_hexa_upper.c | 24 ++++++++++++ lib/my/my_put_nbr.c | 35 +++++++++++++++++ lib/my/my_put_octal.c | 20 ++++++++++ lib/my/my_put_unsigned_nbr.c | 28 ++++++++++++++ lib/my/my_putchar.c | 14 +++++++ lib/my/my_putstr.c | 19 +++++++++ lib/my/my_revstr.c | 22 +++++++++++ lib/my/my_show_word_array.c | 17 +++++++++ lib/my/my_strcat.c | 30 +++++++++++++++ lib/my/my_strcmp.c | 18 +++++++++ lib/my/my_strcpy.c | 20 ++++++++++ lib/my/my_strdup.c | 17 +++++++++ lib/my/my_strlen.c | 16 ++++++++ lib/my/my_strncat.c | 21 ++++++++++ lib/my/my_strncpy.c | 21 ++++++++++ lib/my/my_strpop.c | 21 ++++++++++ lib/my/my_swap.c | 18 +++++++++ src/main.c | 32 ++++++++++++++++ 35 files changed, 879 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 include/radar.h create mode 100644 lib/.gitignore create mode 100644 lib/my/.gitignore create mode 100644 lib/my/Makefile create mode 100644 lib/my/lib.h create mode 100644 lib/my/my_compute_power_rec.c create mode 100644 lib/my/my_compute_square_root.c create mode 100644 lib/my/my_error.c create mode 100644 lib/my/my_format.c create mode 100644 lib/my/my_isneg.c create mode 100644 lib/my/my_printf.c create mode 100644 lib/my/my_put_address.c create mode 100644 lib/my/my_put_float.c create mode 100644 lib/my/my_put_float_upper.c create mode 100644 lib/my/my_put_hexa.c create mode 100644 lib/my/my_put_hexa_upper.c create mode 100644 lib/my/my_put_nbr.c create mode 100644 lib/my/my_put_octal.c create mode 100644 lib/my/my_put_unsigned_nbr.c create mode 100644 lib/my/my_putchar.c create mode 100644 lib/my/my_putstr.c create mode 100644 lib/my/my_revstr.c create mode 100644 lib/my/my_show_word_array.c create mode 100644 lib/my/my_strcat.c create mode 100644 lib/my/my_strcmp.c create mode 100644 lib/my/my_strcpy.c create mode 100644 lib/my/my_strdup.c create mode 100644 lib/my/my_strlen.c create mode 100644 lib/my/my_strncat.c create mode 100644 lib/my/my_strncpy.c create mode 100644 lib/my/my_strpop.c create mode 100644 lib/my/my_swap.c create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8168560 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +my_radar +.idea +.vscode diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a256443 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +## +## EPITECH PROJECT, 2023 +## Makefile +## File description: +## Makefile to build project +## + +NAME = my_radar + +SRCS = src/main.c + +CC = gcc + +CFLAGS = -Iinclude -Llib/my -lmy -l csfml-graphics -l csfml-system -l csfml-window + +all: $(NAME) + +$(NAME): + cd lib/my && make + $(CC) $(SRCS) -o $(NAME) $(CFLAGS) + +clean: + $(RM) *.o + $(RM) $(OBJS) + +fclean: clean + cd lib/my && make fclean + $(RM) $(NAME) + +re: fclean all + +asan: fclean + cd lib/my && make + $(CC) $(SRCS) -o $(NAME) -lasan -g3 $(CFLAGS) diff --git a/include/radar.h b/include/radar.h new file mode 100644 index 0000000..fc30f1f --- /dev/null +++ b/include/radar.h @@ -0,0 +1,16 @@ +/* +** EPITECH PROJECT, 2023 +** B-MUL-100-REN-1-1-myradar-savinien.petitjean +** File description: +** radar.h +*/ + +#ifndef RADAR_H + #define RADAR_H + #include + #include + #include + #include + #include + #include "../lib/my/lib.h" +#endif /* RADAR_H */ diff --git a/lib/.gitignore b/lib/.gitignore new file mode 100644 index 0000000..3086c40 --- /dev/null +++ b/lib/.gitignore @@ -0,0 +1 @@ +libmy.a diff --git a/lib/my/.gitignore b/lib/my/.gitignore new file mode 100644 index 0000000..7a959d2 --- /dev/null +++ b/lib/my/.gitignore @@ -0,0 +1,2 @@ +libmy.a +*.o diff --git a/lib/my/Makefile b/lib/my/Makefile new file mode 100644 index 0000000..99db42d --- /dev/null +++ b/lib/my/Makefile @@ -0,0 +1,58 @@ +## +## EPITECH PROJECT, 2023 +## Makefile +## File description: +## Makefile to build project +## + +NAME = libmy.a + +SRCS = my_compute_power_rec.c \ + my_compute_square_root.c \ + my_put_float.c \ + my_put_float_upper.c \ + my_put_address.c \ + my_isneg.c \ + my_put_nbr.c \ + my_put_unsigned_nbr.c \ + my_put_hexa.c \ + my_put_hexa_upper.c \ + my_put_octal.c \ + my_putchar.c \ + my_putstr.c \ + my_revstr.c \ + my_show_word_array.c \ + my_strcat.c \ + my_strcmp.c \ + my_strcpy.c \ + my_strdup.c \ + my_strlen.c \ + my_strncat.c \ + my_strncpy.c \ + my_swap.c \ + my_printf.c \ + my_format.c \ + my_error.c \ + my_strpop.c + + +OBJS = $(SRCS:.c=.o) + +CC = gcc + +CFLAGS = -c -Iinclude -Wall -Wextra -Werror + +all: $(NAME) + +$(NAME): $(OBJS) + $(CC) $(CFLAGS) $(SRCS) + ar rc $(NAME) $(OBJS) + +clean: + $(RM) *.o + $(RM) $(OBJS) + +fclean: clean + $(RM) $(NAME) + +re: fclean all diff --git a/lib/my/lib.h b/lib/my/lib.h new file mode 100644 index 0000000..846e61c --- /dev/null +++ b/lib/my/lib.h @@ -0,0 +1,60 @@ +/* +** EPITECH PROJECT, 2023 +** Lib/My +** File description: +** ./lib/my/lib.h +*/ + +#ifndef LIB_H_ + #define LIB_H_ + #include + #include + #include +int my_printf(const char *, ...); +int my_format(const char *, int, va_list); +int my_format2(const char *, int, va_list); +int my_format3(const char *, int, va_list); +int my_putchar(char); +int my_isneg(int); +int my_put_nbr(int); +int my_put_unsigned_nbr(unsigned int); +int my_put_hexa(int); +int my_put_address(int); +int my_put_hexa_upper(int); +void my_error(char *); +int my_put_octal(int); +int my_swap(int *, int *); +int my_put_float(float); +int my_put_float_upper(float); +void my_put_float2(int *, int, int, int); +void my_put_float2_upper(int *, int, int, int); +int my_putstr(char const *); +int my_strlen(char const *); +int my_getnbr(char const *); +int my_sort_int_array(int *, int); +int my_compute_power_rec(int, int); +int my_compute_square_root(int); +int my_is_prime(int); +int my_find_prime_sup(int); +char *my_strcpy(char *, char const *); +char *my_strncpy(char *, char const *, int); +char *my_revstr(char *); +char my_strstr(char const *, char const *); +int my_strcmp(char const *, char const *); +int my_strncmp(char const *, char const *, int); +char *my_strupcase(char *); +char *my_strlowcase(char *); +char *my_strcapitalize(char *); +int my_str_isalpha(char const *); +int my_str_isnum(char const *); +int my_str_islower(char const *); +int my_str_isupper(char const *); +int my_str_isprintable(char const *); +int my_showstr(char const *); +int my_showmem(char const *, int); +int my_show_word_array(char *const *); +char *my_strcat(char *, char const *); +char *my_strncat(char *, char const *, int); +char *my_strdup(char const *); +char *my_strpop(char *, int); +#endif /* LIB_H_ */ diff --git a/lib/my/my_compute_power_rec.c b/lib/my/my_compute_power_rec.c new file mode 100644 index 0000000..9716786 --- /dev/null +++ b/lib/my/my_compute_power_rec.c @@ -0,0 +1,20 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_compute_power_rec.c +*/ + +#include "lib.h" + +int my_compute_power_rec(int nb, int p) +{ + int result = 1; + + if (p == 0) + return 1; + if (p < 0) + return 0; + result = my_compute_power_rec(nb, p - 1) * nb; + return (result); +} diff --git a/lib/my/my_compute_square_root.c b/lib/my/my_compute_square_root.c new file mode 100644 index 0000000..f9bef48 --- /dev/null +++ b/lib/my/my_compute_square_root.c @@ -0,0 +1,19 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_compute_square_root.c +*/ + +#include "lib.h" + +int my_compute_square_root(int nb) +{ + if (nb <= 0) + return 0; + for (int i = 1; i <= nb / 2 + 1; i++) { + if (i * i == nb) + return (i); + } + return (0); +} diff --git a/lib/my/my_error.c b/lib/my/my_error.c new file mode 100644 index 0000000..60359eb --- /dev/null +++ b/lib/my/my_error.c @@ -0,0 +1,14 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_isneg.c +*/ + +#include "lib.h" + +void my_error(char *message) +{ + my_printf("%s\n", message); + exit(84); +} diff --git a/lib/my/my_format.c b/lib/my/my_format.c new file mode 100644 index 0000000..2cb4ca6 --- /dev/null +++ b/lib/my/my_format.c @@ -0,0 +1,68 @@ +/* +** EPITECH PROJECT, 2023 +** miniprintf +** File description: +** ./my_format.c +*/ + +#include +#include "lib.h" + +int my_format(const char *format, int i, va_list list) +{ + int count = 1; + + switch (format[i + 1]) { + case '%': + my_putchar('%'); + break; + case 'c': + my_putchar(va_arg(list, int)); + break; + case 'i' : + case 'd' : + case 'n' : + count = my_put_nbr(va_arg(list, int)); + break; + default: + return (my_format2(format, i, list)); + } + return (count); +} + +int my_format2(const char *format, int i, va_list list) +{ + int count = 1; + + switch (format[i + 1]) { + case 'u': + count = my_put_unsigned_nbr(va_arg(list, unsigned int)); + break; + case 'o': + count = my_put_octal(va_arg(list, unsigned int)); + break; + case 'f': + count = my_put_float(va_arg(list, double)); + break; + case 's': + count = my_putstr(va_arg(list, char *)); + break; + default: + return -42; + } + return (count); +} + +int my_format3(const char *format, int i, va_list list) +{ + int count = 1; + + switch (format[i + 1]) { + case 'F': + count = my_put_float_upper(va_arg(list, double)); + break; + default: + return -42; + } + return (count); +} diff --git a/lib/my/my_isneg.c b/lib/my/my_isneg.c new file mode 100644 index 0000000..3e5f70d --- /dev/null +++ b/lib/my/my_isneg.c @@ -0,0 +1,17 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_isneg.c +*/ + +#include "lib.h" + +int my_isneg(int n) +{ + if (n < 0) + my_putchar('N'); + else + my_putchar('P'); + return (0); +} diff --git a/lib/my/my_printf.c b/lib/my/my_printf.c new file mode 100644 index 0000000..25fb85a --- /dev/null +++ b/lib/my/my_printf.c @@ -0,0 +1,30 @@ +/* +** EPITECH PROJECT, 2023 +** miniprintf +** File description: +** ./mini_printf.c +*/ + +#include +#include "lib.h" + +int my_printf(const char *format, ...) +{ + va_list list; + int count = 0; + + if (format == 0) + return -42; + va_start(list, format); + for (int i = 0; i < my_strlen(format); i++) { + if (format[i] == '%') { + count += my_format(format, i, list); + i++; + } else { + my_putchar(format[i]); + count++; + } + } + va_end(list); + return count; +} diff --git a/lib/my/my_put_address.c b/lib/my/my_put_address.c new file mode 100644 index 0000000..6767a9d --- /dev/null +++ b/lib/my/my_put_address.c @@ -0,0 +1,26 @@ +/* +** EPITECH PROJECT, 2023 +** my_put_adress.c +** File description: +** my_put_adress.c +*/ + +#include "lib.h" + +int my_put_address(int nb) +{ + int i = 0; + + if (nb < 0) { + my_putchar('-'); + nb = nb * (-1); + } + if (nb >= 10) { + i = (nb % 10); + nb = (nb - i) / 10; + my_put_nbr(nb); + my_putchar(i + 48); + } else + my_putchar(nb + 48); + return (0); +} diff --git a/lib/my/my_put_float.c b/lib/my/my_put_float.c new file mode 100644 index 0000000..abbd214 --- /dev/null +++ b/lib/my/my_put_float.c @@ -0,0 +1,47 @@ +/* +** EPITECH PROJECT, 2023 +** my_put_float +** File description: +** my_put_float.c +*/ + +#include "lib.h" + +int my_put_float(float nb) +{ + int x = 0; + int entier = nb; + int precision = 6; + int decimal[precision]; + int b = 10; + int tt; + + for (int i = 0; i < precision; i++) { + tt = (int)(nb * b); + decimal[i] = tt % 10; + b = b * 10; + } + if (nb < 0) { + my_putchar('-'); + nb = nb * -1; + entier = nb; + } + my_put_float2(decimal, x, precision, entier); + return (0); +} + +void my_put_float2( + int *decimal, + int x, + int precision, + int entier +) +{ + x += my_put_nbr(entier); + my_putchar('.'); + x++; + for (int i = 0; i < precision; i++) { + if (decimal[i] != 0) + x += my_put_nbr(decimal[i]); + } +} diff --git a/lib/my/my_put_float_upper.c b/lib/my/my_put_float_upper.c new file mode 100644 index 0000000..56fecbc --- /dev/null +++ b/lib/my/my_put_float_upper.c @@ -0,0 +1,47 @@ +/* +** EPITECH PROJECT, 2023 +** my_put_float_upper +** File description: +** ./my_put_float_upper.c +*/ + +#include "lib.h" + +int my_put_float_upper(float nb) +{ + int x = 0; + int entier = nb; + int precision = 6; + int decimal[precision]; + int b = 10; + int tt; + + for (int i = 0; i < precision; i++) { + tt = (int)(nb * b); + decimal[i] = tt % 10; + b = b * 10; + } + if (nb < 0) { + my_putchar('-'); + nb = nb * -1; + entier = nb; + } + my_put_float2_upper(decimal, x, precision, entier); + return (0); +} + +void my_put_float2_upper( + int *decimal, + int x, + int precision, + int entier +) +{ + x += my_put_nbr(entier); + my_putchar('.'); + x++; + for (int i = 0; i < precision; i++) { + if (decimal[i] != 0) + x += my_put_nbr(decimal[i]); + } +} diff --git a/lib/my/my_put_hexa.c b/lib/my/my_put_hexa.c new file mode 100644 index 0000000..2a24ab8 --- /dev/null +++ b/lib/my/my_put_hexa.c @@ -0,0 +1,24 @@ +/* +** EPITECH PROJECT, 2023 +** my_put_hexa +** File description: +** ./my_put_hexa.c +*/ + +#include "lib.h" + +int my_put_hexa(int nb) +{ + int result = nb; + + while (nb != 0) { + result = nb % 16; + if (result < 10) { + my_putchar(result + 48); + } else { + my_putchar(result + 87); + } + nb = nb / 16; + } + return (0); +} diff --git a/lib/my/my_put_hexa_upper.c b/lib/my/my_put_hexa_upper.c new file mode 100644 index 0000000..5021bd8 --- /dev/null +++ b/lib/my/my_put_hexa_upper.c @@ -0,0 +1,24 @@ +/* +** EPITECH PROJECT, 2023 +** my_put_hexa_upper +** File description: +** ./my_put_hexa_upper.c +*/ + +#include "lib.h" + +int my_put_hexa_upper(int nb) +{ + int result = nb; + + while (nb != 0) { + result = nb % 16; + if (result < 10) { + my_putchar(result + 48); + } else { + my_putchar(result + 5); + } + nb = nb / 16; + } + return (0); +} diff --git a/lib/my/my_put_nbr.c b/lib/my/my_put_nbr.c new file mode 100644 index 0000000..4c53f63 --- /dev/null +++ b/lib/my/my_put_nbr.c @@ -0,0 +1,35 @@ +/* +** EPITECH PROJECT, 2023 +** SH_PUTNBR +** File description: +** Outputs a given int. +*/ + +#include "lib.h" + +static void my_put_positive(int nb, int *count) +{ + if (nb > 9) + my_put_positive(nb / 10, count); + my_putchar(nb % 10 + '0'); + count++; +} + +int my_put_nbr(int nb) +{ + int output = nb; + int count = 0; + + if (nb < 0) { + my_putchar('-'); + count++; + output = -nb; + } + if (output < 0) { + output = -(output / 10); + my_put_positive(output, &count); + my_put_positive(-(nb % 10), &count); + } else + my_put_positive(output, &count); + return (count); +} diff --git a/lib/my/my_put_octal.c b/lib/my/my_put_octal.c new file mode 100644 index 0000000..0f71d11 --- /dev/null +++ b/lib/my/my_put_octal.c @@ -0,0 +1,20 @@ +/* +** EPITECH PROJECT, 2023 +** my_put_octal +** File description: +** ./my_put_octal.c +*/ + +#include "lib.h" + +int my_put_octal(int nb) +{ + int result = nb; + + while (nb != 0) { + result = nb % 8; + my_putchar(result + 48); + nb = nb / 8; + } + return (0); +} diff --git a/lib/my/my_put_unsigned_nbr.c b/lib/my/my_put_unsigned_nbr.c new file mode 100644 index 0000000..bfcafbc --- /dev/null +++ b/lib/my/my_put_unsigned_nbr.c @@ -0,0 +1,28 @@ +/* +** EPITECH PROJECT, 2023 +** MyPrintf +** File description: +** Outputs a given int. +*/ + +#include "lib.h" + +void my_put_positive(int nb) +{ + if (nb > 9) + my_put_positive(nb / 10); + my_putchar(nb % 10 + '0'); +} + +int my_put_unsigned_nbr(unsigned int nb) +{ + int output = nb; + + if (output < 0) { + output = -(output / 10); + my_put_positive(output); + my_put_positive(-(nb % 10)); + } else + my_put_positive(output); + return (0); +} diff --git a/lib/my/my_putchar.c b/lib/my/my_putchar.c new file mode 100644 index 0000000..f7ae6ae --- /dev/null +++ b/lib/my/my_putchar.c @@ -0,0 +1,14 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_putchar.c +*/ + +#include "lib.h" + +int my_putchar(char a) +{ + write(1, &a, 1); + return (0); +} diff --git a/lib/my/my_putstr.c b/lib/my/my_putstr.c new file mode 100644 index 0000000..1e78213 --- /dev/null +++ b/lib/my/my_putstr.c @@ -0,0 +1,19 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_putstr.c +*/ + +#include "lib.h" + +int my_putstr(char const *str) +{ + int count = 0; + + for (int i = 0; str[i] != '\0'; i++) { + my_putchar(str[i]); + count++; + } + return (count); +} diff --git a/lib/my/my_revstr.c b/lib/my/my_revstr.c new file mode 100644 index 0000000..34d21e0 --- /dev/null +++ b/lib/my/my_revstr.c @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_revstr.c +*/ + +#include "lib.h" + +char *my_revstr(char *str) +{ + int i; + char swap; + + for (i = 0; str[i] != '\0'; i++); + for (int j = 0; j < i / 2; j++) { + swap = str[j]; + str[j] = str[i - j - 1]; + str[i - j - 1] = swap; + } + return str; +} diff --git a/lib/my/my_show_word_array.c b/lib/my/my_show_word_array.c new file mode 100644 index 0000000..127bd55 --- /dev/null +++ b/lib/my/my_show_word_array.c @@ -0,0 +1,17 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay08 +** File description: +** ./lin/my/my_show_word_array.c +*/ + +#include "lib.h" + +int my_show_word_array(char *const *tab) +{ + for (int i = 0; tab[i] != 0; i++) { + my_putstr(tab[i]); + my_putchar('\n'); + } + return 0; +} diff --git a/lib/my/my_strcat.c b/lib/my/my_strcat.c new file mode 100644 index 0000000..22f90d1 --- /dev/null +++ b/lib/my/my_strcat.c @@ -0,0 +1,30 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_strcat.c +*/ + +#include "lib.h" +#include + +char *my_strcat(char *dest, char const *src) +{ + int i; + int count; + char *res; + + i = 0; + count = 0; + res = malloc(sizeof(*res) * (my_strlen(dest) + my_strlen(src) + 1)); + while (dest[i]) { + res[i] = dest[i]; + i++; + } + while (src[count]) { + res[i + count] = src[count]; + count++; + } + res[i + count] = '\0'; + return (res); +} diff --git a/lib/my/my_strcmp.c b/lib/my/my_strcmp.c new file mode 100644 index 0000000..fc46aa9 --- /dev/null +++ b/lib/my/my_strcmp.c @@ -0,0 +1,18 @@ +/* +** EPITECH PROJECT, 2023 +** B-PSU-100-REN-1-1-bsmyls-savinien.petitjean +** File description: +** ./my_strcmp.c +*/ + +#include "lib.h" + +int my_strcmp(char const *s1, char const *s2) +{ + int i = 0; + + while (s1[i] == s2[i] && s1[i] != '\0') { + i++; + } + return s1[i] - s2[i]; +} diff --git a/lib/my/my_strcpy.c b/lib/my/my_strcpy.c new file mode 100644 index 0000000..340719f --- /dev/null +++ b/lib/my/my_strcpy.c @@ -0,0 +1,20 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_strcpy.c +*/ + +#include "lib.h" + +char *my_strcpy(char *dest, char const *src) +{ + int i = 0; + + while (src[i] != '\0') { + dest[i] = src[i]; + i++; + } + dest[i] = '\0'; + return dest; +} diff --git a/lib/my/my_strdup.c b/lib/my/my_strdup.c new file mode 100644 index 0000000..aef66a5 --- /dev/null +++ b/lib/my/my_strdup.c @@ -0,0 +1,17 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay08 +** File description: +** ./my_strdup.c +*/ + +#include "lib.h" + +char *my_strdup(char const *src) +{ + char *dest; + int len = my_strlen(src); + + dest = malloc(sizeof(char) * (len + 1)); + return my_strcpy(dest, src); +} diff --git a/lib/my/my_strlen.c b/lib/my/my_strlen.c new file mode 100644 index 0000000..f9885bd --- /dev/null +++ b/lib/my/my_strlen.c @@ -0,0 +1,16 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_strlen.c +*/ + +#include "lib.h" + +int my_strlen(char const *str) +{ + int i; + + for (i = 0; str[i] != '\0'; i++); + return (i); +} diff --git a/lib/my/my_strncat.c b/lib/my/my_strncat.c new file mode 100644 index 0000000..33a140c --- /dev/null +++ b/lib/my/my_strncat.c @@ -0,0 +1,21 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_strncat.c +*/ + +#include "lib.h" + +char *my_strncat(char *dest, char const *src, int nb) +{ + int i = 0; + int len = my_strlen(dest); + + while (src[i] != '\0' && i < nb) { + dest[i + len] = src[i]; + i++; + } + dest[i + len] = '\0'; + return dest; +} diff --git a/lib/my/my_strncpy.c b/lib/my/my_strncpy.c new file mode 100644 index 0000000..399917c --- /dev/null +++ b/lib/my/my_strncpy.c @@ -0,0 +1,21 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_strncpy.c +*/ + +#include "lib.h" + +char *my_strncpy(char *dest, char const *src, int n) +{ + int i = 0; + + while (i < n && src[i] != '\0') { + dest[i] = src[i]; + i++; + } + if (src[i] == '\0' && i < n) + dest[i] = '\0'; + return dest; +} diff --git a/lib/my/my_strpop.c b/lib/my/my_strpop.c new file mode 100644 index 0000000..603ef69 --- /dev/null +++ b/lib/my/my_strpop.c @@ -0,0 +1,21 @@ +/* +** EPITECH PROJECT, 2023 +** B-PSU-100-REN-1-1-myls-savinien.petitjean +** File description: +** lib/mu/my_strpop.c +*/ + +#include +#include "lib.h" + +char *my_strpop(char *str, int size) +{ + int l = my_strlen(str); + char *strr = malloc(l - size); + + for (int i = 0; i < l - size; i++) { + strr[i] = str[i]; + } + strr[l - size] = '\0'; + return strr; +} diff --git a/lib/my/my_swap.c b/lib/my/my_swap.c new file mode 100644 index 0000000..119bb8c --- /dev/null +++ b/lib/my/my_swap.c @@ -0,0 +1,18 @@ +/* +** EPITECH PROJECT, 2023 +** CPoolDay07 +** File description: +** ./my_swap.c +*/ + +#include "lib.h" + +int my_swap(int *a, int *b) +{ + int swap; + + swap = *a; + *a = *b; + *b = swap; + return (0); +} diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..6f739ad --- /dev/null +++ b/src/main.c @@ -0,0 +1,32 @@ +/* +** EPITECH PROJECT, 2023 +** B-CPE-110-REN-1-1-organized-nathan.barbet +** File description: +** main.c +*/ + +#include "../include/radar.h" +#include +#include +#include +int main() +{ + sfVideoMode mode = {1920, 1080, 32}; + sfRenderWindow* window; + sfEvent event; + window = sfRenderWindow_create(mode, "My Radar", sfResize | sfClose, NULL); + if (!window) + return EXIT_FAILURE; + while (sfRenderWindow_isOpen(window)) + { + while (sfRenderWindow_pollEvent(window, &event)) + { + if (event.type == sfEvtClosed) + sfRenderWindow_close(window); + } + sfRenderWindow_clear(window, sfBlack); + sfRenderWindow_display(window); + } + sfRenderWindow_destroy(window); + return EXIT_SUCCESS; +}