0
0
This commit is contained in:
Guy Baconniere
2021-08-22 18:10:08 +02:00
parent 2e3daba75a
commit 886ab5481c
44 changed files with 774 additions and 11 deletions

BIN
C_02/git/ex00/a.out Executable file

Binary file not shown.

BIN
C_03/git/ex01/a.out Executable file

Binary file not shown.

BIN
C_05/git/ex04/a.out Executable file

Binary file not shown.

BIN
C_07/git/ex02/a.out Executable file

Binary file not shown.

Binary file not shown.

21
C_08/git_old/ex00/ft.h Normal file
View File

@@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/20 10:17:09 by gbaconni #+# #+# */
/* Updated: 2021/08/20 12:05:50 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_H
# define FT_H
void ft_putchar(char c);
void ft_swap(int *a, int *b);
void ft_putstr(char *str);
int ft_strlen(char *str);
int ft_strcmp(char *s1, char *s2);
#endif

19
C_08/git_old/ex00/main.c Normal file
View File

@@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/20 10:26:50 by gbaconni #+# #+# */
/* Updated: 2021/08/20 10:34:14 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft.h"
int main(int argc, char *argv[])
{
(void) argc;
(void) argv;
}

14
C_08/git_old/ex00/main.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
set -e
rm -f a.out
find . -type f -name '*.h' -exec \
norminette -R CheckDefine {} \;
find . -type f -name '*.c' \! -name 'main.c' -exec \
norminette -R CheckForbiddenSourceHeader {} \;
echo
gcc -Wall -Wextra -Werror -o a.out *.c
#cpp *.c | tail -n 30
echo
echo $(basename $PWD):
./a.out "$@"
rm -f a.out

View File

@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_boolean.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/20 10:17:09 by gbaconni #+# #+# */
/* Updated: 2021/08/22 15:41:04 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_BOOLEAN_H
# define FT_BOOLEAN_H
# include <unistd.h>
typedef int t_bool;
# define TRUE 1
# define FALSE 0
# define EVEN(nbr) nbr % 2 == 0
# define EVEN_MSG "I have an even number of arguments.\n"
# define ODD_MSG "I have an odd number of arguments.\n"
# define SUCCESS 0
#endif

34
C_08/git_old/ex01/main.c Normal file
View File

@@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/20 10:26:50 by gbaconni #+# #+# */
/* Updated: 2021/08/20 10:34:14 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_boolean.h"
void ft_putstr(char *str)
{
while (*str)
write(1, str++, 1);
}
t_bool ft_is_even(int nbr)
{
return ((EVEN(nbr)) ? TRUE : FALSE);
}
int main(int argc, char **argv)
{
(void) argv;
if (ft_is_even(argc - 1) == TRUE)
ft_putstr(EVEN_MSG);
else
ft_putstr(ODD_MSG);
return (SUCCESS);
}

14
C_08/git_old/ex01/main.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
set -e
rm -f a.out
find . -type f -name '*.h' -exec \
norminette -R CheckDefine {} \;
find . -type f -name '*.c' \! -name 'main.c' -exec \
norminette -R CheckForbiddenSourceHeader {} \;
echo
gcc -Wall -Wextra -Werror -o a.out *.c
#cpp *.c | tail -n 30
echo
echo $(basename $PWD):
./a.out "$@"
rm -f a.out

View File

@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_boolean.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/20 10:17:09 by gbaconni #+# #+# */
/* Updated: 2021/08/22 15:39:27 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_ABS_H
# define FT_ABS_H
# define ABS(Value) ((Value < 0)? (-Value): (Value))
#endif

52
C_08/git_old/ex02/main.c Normal file
View File

@@ -0,0 +1,52 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/20 10:26:50 by gbaconni #+# #+# */
/* Updated: 2021/08/20 10:34:14 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_abs.h"
#include <stdio.h>
static int ft_atoi(char *str)
{
int nb;
int s;
int i;
nb = 0;
s = 1;
i = 0;
while (str[i] != '\0' && (str[i] == ' ' || (str[i] >= '\t' && str[i] <= '\r')))
i++;
while (str[i] != '\0')
{
if (str[i] == '+')
s += 0;
else if (str[i] == '-')
s *= -1;
else if (str[i] >= '0' && str[i] <= '9')
nb = nb * 10 + str[i] - '0';
else
break ;
i++;
}
return (nb * s);
}
int main(int argc, char *argv[])
{
int n;
if (argc > 1)
{
n = ft_atoi(argv[1]);
printf("%d\n", ABS(n));
}
return (0);
}

14
C_08/git_old/ex02/main.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
set -e
rm -f a.out
find . -type f -name '*.h' -exec \
norminette -R CheckDefine {} \;
find . -type f -name '*.c' \! -name 'main.c' -exec \
norminette -R CheckForbiddenSourceHeader {} \;
echo
gcc -Wall -Wextra -Werror -o a.out *.c
#cpp *.c | tail -n 30
echo
echo $(basename $PWD):
./a.out "$@"
rm -f a.out

View File

@@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_point.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/20 10:17:09 by gbaconni #+# #+# */
/* Updated: 2021/08/20 12:05:50 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_POINT_H
# define FT_POINT_H
typedef struct s_point
{
int x;
int y;
} t_point;
void set_point(t_point *point);
#endif

27
C_08/git_old/ex03/main.c Normal file
View File

@@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/20 10:26:50 by gbaconni #+# #+# */
/* Updated: 2021/08/20 10:34:14 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_point.h"
void set_point(t_point *point)
{
point->x = 42;
point->y = 21;
}
int main(void)
{
t_point point;
set_point(&point);
return (0);
}

14
C_08/git_old/ex03/main.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
set -e
rm -f a.out
find . -type f -name '*.h' -exec \
norminette -R CheckDefine {} \;
find . -type f -name '*.c' \! -name 'main.c' -exec \
norminette -R CheckForbiddenSourceHeader {} \;
echo
gcc -Wall -Wextra -Werror -o a.out *.c
#cpp *.c | tail -n 30
echo
echo $(basename $PWD):
./a.out "$@"
rm -f a.out

View File

@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/22 14:41:08 by gbaconni #+# #+# */
/* Updated: 2021/08/22 14:41:17 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}

22
C_09/git/ex00/ft_putstr.c Normal file
View File

@@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/22 14:42:02 by gbaconni #+# #+# */
/* Updated: 2021/08/22 14:42:04 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putstr(char *str)
{
char *p_str;
p_str = str;
while (*p_str != '\0')
write(1, p_str++, 1);
}

28
C_09/git/ex00/ft_strcmp.c Normal file
View File

@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/22 14:43:35 by gbaconni #+# #+# */
/* Updated: 2021/08/22 14:43:44 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strcmp(char *s1, char *s2)
{
char c1;
char c2;
c1 = '\0';
c2 = '\0';
while (c1 == c2)
{
c1 = *s1++;
c2 = *s2++;
if (c1 == '\0')
break ;
}
return (c1 - c2);
}

21
C_09/git/ex00/ft_strlen.c Normal file
View File

@@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/22 14:42:47 by gbaconni #+# #+# */
/* Updated: 2021/08/22 14:43:21 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strlen(char *str)
{
char *p_str;
p_str = str;
while (*p_str != '\0')
p_str++;
return (p_str - str);
}

20
C_09/git/ex00/ft_swap.c Normal file
View File

@@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_swap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/22 14:41:30 by gbaconni #+# #+# */
/* Updated: 2021/08/22 14:41:35 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
void ft_swap(int *a, int *b)
{
int n;
n = *a;
*a = *b;
*b = n;
}

6
C_09/git/ex00/libft_creator.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
rm -f *.o libft.a
gcc -Wall -Wextra -Werror -c *.c
ar -cq libft.a *.o
#ar -t libft.a
#rm -f *.o

View File

@@ -5,15 +5,42 @@
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/20 10:26:50 by gbaconni #+# #+# */
/* Updated: 2021/08/20 10:34:14 by gbaconni ### ########.fr */
/* Created: 2021/08/22 14:55:33 by gbaconni #+# #+# */
/* Updated: 2021/08/22 17:19:48 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
void ft_putchar(char c);
void ft_swap(int *a, int *b);
void ft_putstr(char *str);
int ft_strlen(char *str);
int ft_strcmp(char *s1, char *s2);
int main(void)
{
(void) argc;
(void) argv;
int a;
int b;
int r;
printf("ft_putchar: (expected Z)\n");
ft_putchar('Z');
printf("\n\n");
a = 42;
b = 21;
printf("ft_swap: (expected a=21 b=42)\n");
ft_swap(&a, &b);
printf("a=%d b=%d\n\n", a, b);
printf("ft_putstr: (expected hello)\n");
ft_putstr("hello\n\n");
printf("ft_strlen: (expected 5)\n");
r = ft_strlen("hello");
printf("%d\n\n", r);
printf("ft_strcmp: (expected 0)\n");
r = ft_strcmp("abc","abc");
printf("%d\n\n", r);
}

View File

@@ -1,8 +1,14 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckDefine -R CheckForbiddenSourceHeader *.c
gcc -Wall -Wextra -Werror -o a.out *.c
find . -type f -name '*.h' -exec \
norminette -R CheckDefine {} \;
find . -type f -name '*.c' \! -name 'main.c' -exec \
norminette -R CheckForbiddenSourceHeader {} \;
echo
sh libft_creator.sh
rm -f *.o
echo
echo $(basename $PWD):
./a.out
gcc -Wall -Wextra -Werror -o a.out -L. -lft main.c
./a.out "$@"
rm -f a.out

50
C_09/git/ex01/Makefile Normal file
View File

@@ -0,0 +1,50 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/08/22 17:28:57 by gbaconni #+# #+# #
# Updated: 2021/08/22 17:43:24 by gbaconni ### ########.fr #
# #
# **************************************************************************** #
#
# make fclean
# make
#
NAME = libft.a
SRCDIR = srcs
SRC = ft_putchar.c \
ft_swap.c \
ft_putstr.c \
ft_strlen.c \
ft_strcmp.c
HDR = ft.h
INCLUDE = includes
CC = gcc
CFLAGS = -Wall -Wextra -Werror
AR = ar
ARFLAGS = -cq
all: $(NAME)
$(NAME):
cd $(SRCDIR) && $(CC) $(CFLAGS) -I $(INCLUDE) -c $(SRC)
$(AR) $(ARFLAGS) $(NAME) $(SRCDIR)/*.o
clean:
@/bin/rm -f **/*.o
fclean: clean
@/bin/rm -f $(NAME)
re: fclean all

View File

@@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/20 10:17:09 by gbaconni #+# #+# */
/* Updated: 2021/08/22 17:40:13 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_H
# define FT_H
void ft_putchar(char c);
void ft_swap(int *a, int *b);
void ft_putstr(char *str);
int ft_strlen(char *str);
int ft_strcmp(char *s1, char *s2);
#endif

46
C_09/git/ex01/main.c Normal file
View File

@@ -0,0 +1,46 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/22 14:55:33 by gbaconni #+# #+# */
/* Updated: 2021/08/22 17:19:48 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
void ft_putchar(char c);
void ft_swap(int *a, int *b);
void ft_putstr(char *str);
int ft_strlen(char *str);
int ft_strcmp(char *s1, char *s2);
int main(void)
{
int a;
int b;
int r;
printf("ft_putchar: (expected Z)\n");
ft_putchar('Z');
printf("\n\n");
a = 42;
b = 21;
printf("ft_swap: (expected a=21 b=42)\n");
ft_swap(&a, &b);
printf("a=%d b=%d\n\n", a, b);
printf("ft_putstr: (expected hello)\n");
ft_putstr("hello\n\n");
printf("ft_strlen: (expected 5)\n");
r = ft_strlen("hello");
printf("%d\n\n", r);
printf("ft_strcmp: (expected 0)\n");
r = ft_strcmp("abc","abc");
printf("%d\n\n", r);
}

15
C_09/git/ex01/main.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
set -e
find . -type f -name '*.h' -exec \
norminette -R CheckDefine {} \;
find . -type f -name '*.c' \! -name 'main.c' -exec \
norminette -R CheckForbiddenSourceHeader {} \;
echo
make fclean
make
rm -f *.o
echo
echo $(basename $PWD):
gcc -Wall -Wextra -Werror -o a.out -L. -lft main.c
./a.out "$@"
rm -f a.out

View File

@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/22 14:41:08 by gbaconni #+# #+# */
/* Updated: 2021/08/22 14:41:17 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}

View File

@@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/22 14:42:02 by gbaconni #+# #+# */
/* Updated: 2021/08/22 14:42:04 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putstr(char *str)
{
char *p_str;
p_str = str;
while (*p_str != '\0')
write(1, p_str++, 1);
}

View File

@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/22 14:43:35 by gbaconni #+# #+# */
/* Updated: 2021/08/22 14:43:44 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strcmp(char *s1, char *s2)
{
char c1;
char c2;
c1 = '\0';
c2 = '\0';
while (c1 == c2)
{
c1 = *s1++;
c2 = *s2++;
if (c1 == '\0')
break ;
}
return (c1 - c2);
}

View File

@@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/22 14:42:47 by gbaconni #+# #+# */
/* Updated: 2021/08/22 14:43:21 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strlen(char *str)
{
char *p_str;
p_str = str;
while (*p_str != '\0')
p_str++;
return (p_str - str);
}

View File

@@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_swap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/22 14:41:30 by gbaconni #+# #+# */
/* Updated: 2021/08/22 14:41:35 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
void ft_swap(int *a, int *b)
{
int n;
n = *a;
*a = *b;
*b = n;
}

View File

@@ -6,16 +6,113 @@
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/21 18:36:54 by gbaconni #+# #+# */
/* Updated: 2021/08/21 18:58:39 by gbaconni ### ########.fr */
/* Updated: 2021/08/22 14:00:53 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include "../ft/ft.h"
// cc -Wall -Wextra -Werror -o a.out -L../ft -lft compute.c && ./a.out && rm a.out
char *ft_strrev(char *str)
{
int size;
int i;
int j;
char c;
size = ft_strlen(str);
j = 0;
i = 0;
while (i < (size / 2))
{
j = size - 1 - i;
c = str[i];
str[i] = str[j];
str[j] = c;
i++;
}
return (str);
}
char ft_nextchar(char *str)
{
char c;
if (*str != '\0')
c = *str++;
else
c = *str;
return (c);
}
char *ft_one_zeros(int n)
{
char *str;
char *start;
str = (char *) malloc((n + 2) * sizeof(char));
start = str;
*str++ = '1';
while (n > 0 && n--)
*str++ = '0';
*str = '\0';
str = start;
return (str);
}
#define DEBUG 1
char *ft_split3(char *str)
{
char *num;
char c;
int i;
int len;
i = 0;
len = ft_strlen(str);
while (*str != '\0' && i < len % 3 && len % 3 != 0 && len > 3)
{
len = ft_strlen(str);
c = ft_nextchar(str);
ft_putchar(c);
str++;
i++;
}
if (i != 0)
{
ft_putstr("'");
num = ft_one_zeros(ft_strlen(str) - 1);
#if DEBUG > 0
printf("\nzeros=%s\n", num);
#endif
free(num);
}
i = 0;
while (*str != '\0')
{
c = ft_nextchar(str);
ft_putchar(c);
if (i % 3 == 2 && i < len - 1)
{
ft_putstr("'");
num = ft_one_zeros(ft_strlen(str) - 1);
#if DEBUG > 0
printf("\nzeros=%s\n", num);
#endif
free(num);
}
str++;
i++;
}
return (str);
}
int main(int argc, char *argv[])
{
char *str;
@@ -25,6 +122,8 @@ int main(int argc, char *argv[])
str = argv[1];
ft_putstr(str);
ft_putstr(" => ");
(void) ft_split3(str);
ft_putstr("\n");
return (0);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.