Compare commits

...

2 Commits

Author SHA1 Message Date
Camille Chauvet
8371b01390 clean: remove compile file 2023-05-17 13:26:16 +02:00
Camille Chauvet
3e9f5e829f fix: replace write by printf 2023-05-17 13:25:34 +02:00
6 changed files with 4 additions and 120 deletions

View File

@ -1,8 +1,5 @@
SRCS = parsing.c \ SRCS = parsing.c \
utils/ft_isnum.c \ utils/ft_isnum.c \
utils/putchar.c \
utils/putnum.c \
utils/putstr.c \
utils/ft_atoi.c \ utils/ft_atoi.c \
main.c \ main.c \
time.c \ time.c \

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 11:33:33 by cchauvet #+# #+# */ /* Created: 2023/04/27 11:33:33 by cchauvet #+# #+# */
/* Updated: 2023/04/27 11:43:42 by cchauvet ### ########.fr */ /* Updated: 2023/05/17 13:22:19 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -30,12 +30,7 @@ static void print(t_data *data, size_t id, char *str)
if (stop == false) if (stop == false)
{ {
time = get_time(); time = get_time();
ft_putnum(time, 7); printf("%zu %zu %s\n", time, id, str);
ft_putchar(' ');
ft_putnum(id + 1, 3);
ft_putchar(' ');
ft_putstr(str);
ft_putchar('\n');
} }
pthread_mutex_unlock(&data->print_mutex); pthread_mutex_unlock(&data->print_mutex);
} }

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 11:41:14 by cchauvet #+# #+# */ /* Created: 2023/04/27 11:41:14 by cchauvet #+# #+# */
/* Updated: 2023/04/27 11:41:46 by cchauvet ### ########.fr */ /* Updated: 2023/05/17 13:21:33 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -22,11 +22,6 @@ void print_died(t_philo *philo)
data = philo->data; data = philo->data;
time = get_time(); time = get_time();
pthread_mutex_lock(&data->print_mutex); pthread_mutex_lock(&data->print_mutex);
ft_putnum(time, 7); printf("%7zu %3zu %s\n", time, philo->id, "died");
ft_putchar(' ');
ft_putnum(philo->id + 1, 3);
ft_putchar(' ');
ft_putstr("died");
ft_putchar('\n');
pthread_mutex_unlock(&data->print_mutex); pthread_mutex_unlock(&data->print_mutex);
} }

View File

@ -1,18 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* putchar.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 11:28:09 by cchauvet #+# #+# */
/* Updated: 2023/04/27 11:28:10 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}

View File

@ -1,59 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* putnum.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 11:28:00 by cchauvet #+# #+# */
/* Updated: 2023/04/27 11:28:01 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stddef.h>
#include <unistd.h>
#include <stdlib.h>
#include "utils.h"
static size_t get_size(size_t num)
{
size_t nb_digit;
size_t rest;
nb_digit = 0;
if (num == 0)
nb_digit++;
rest = num;
while (rest != 0)
{
nb_digit++;
rest = rest / 10;
}
return (nb_digit);
}
static void ft_putdigit(size_t num)
{
if (num > 9)
{
ft_putdigit(num / 10);
ft_putchar(num % 10 + 48);
}
else
ft_putchar(num + 48);
}
void ft_putnum(size_t num, size_t padding)
{
size_t size;
size_t i;
i = 0;
size = get_size(num);
while (i < padding - size)
{
ft_putchar('0');
i++;
}
ft_putdigit(num);
}

View File

@ -1,26 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* putstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 11:28:26 by cchauvet #+# #+# */
/* Updated: 2023/04/27 11:28:27 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "utils.h"
#include <stddef.h>
void ft_putstr(char *str)
{
size_t i;
i = 0;
while (str[i] != 0)
{
ft_putchar(str[i]);
i++;
}
}