#include "philo.h"

void	*philo_exec(void *arg)
{
	t_philo	*philo;

	philo = (t_philo*)arg;
	while (1)
	{
		write(1, philo->str, ft_strlen(philo->str));
		write(1, " nb ", 4);
		ft_putnbr_fd(philo->nbr, 1);
		write(1, "\n", 1);
		sleep (1);
	}
}

int	main(void)
{
	pthread_t	*tid;
	int			n_philo;
	int			i;
	t_philo		*philo;

	n_philo = 3;
	philo = malloc(sizeof(philo) * n_philo);
	tid = malloc(sizeof(pthread_t) * n_philo);
	i = 0;
	while (i < n_philo)
	{
		philo[i].str = "i'm philosopher";
		philo[i].nbr = i;
		pthread_create(&tid[i], NULL, &philo_exec, &philo[i]);
		i++;
	}
	while (1)
	{
		write(1, "main function\n", 14);      
		sleep (1);
	}
    return 0;
}

