Esempio n. 1
0
int		getnbr_fd(t_game *game)
{
	char	*nbr;
	int		ret;
	int		play;

	play = 0;
	if ((ret = get_next_line(0, &nbr)))
		if (ft_check_data(nbr) || !*nbr)
		{
			ft_putendl_fd("U must only type digit", 2);
			return (0);
		}
	if (ret == -1)
	{
		ft_putendl_fd("file not found", 2);//error
		return (0);
	}
	play = ft_atoi(nbr);
	if (play >= game->col || play < 0)
	{
		ft_putendl_fd("U cant play on this column", 2);
		return (0);
	}
	if (put_coin(game->tab, *game, play))//si je peu plus deposer le pion
	{
			ft_putendl_fd("This column is already full", 2);
		return (0);
	}
	return (1);
}
Esempio n. 2
0
static void			print_data(int cc, struct icmp *icp, struct ip *ip, double triptime)
{
	printf(" ttl=%d", ip->ip_ttl);
	if (triptime >= 100)
		printf(" time=%f ms\n", triptime);
	else if (triptime >= 10)
		printf(" time=%.1f ms\n", triptime);
	else if (triptime >= 1)
		printf(" time=%.2f ms\n", triptime);
	else
		printf(" time=%.3f ms\n", triptime);
	ft_check_data(icp, cc);
	fflush(stdout);
}