iBusiness
42 Piscine, Day08 -...
 
Share:
Notifications
Clear all

42 Piscine, Day08 - ex06 ft_show_tab.c  

  RSS

Isaac More
(@isaacmore)
Member Admin
Joined: 1 year ago
Posts: 189
19/06/2020 11:03 am  
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_show_tab.c                                      :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rariosa- <rariosa-@student.42.fr>          +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2017/08/18 23:03:26 by rariosa-          #+#    #+#             */
/*   Updated: 2017/08/18 23:43:25 by rariosa-         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "ft_stock_par.h"

void	ft_putchar(char c);

void	ft_putnbr(int nb)
{
	if (nb == -2147483648)
	{
		ft_putchar('-');
		ft_putchar('2');
		ft_putnbr(147483648);
	}
	else if (nb < 0)
	{
		ft_putchar('-');
		ft_putnbr(nb * (-1));
	}
	else
	{
		if (nb >= 10)
			ft_putnbr(nb / 10);
		ft_putchar((nb % 10) + '0');
	}
}

void	ft_putstr(char *str)
{
	while (*str != '')
		ft_putchar(*str++);
}

void	ft_show_tab(struct s_stock_par *par)
{
	int i;
	int j;

	i = 0;
	while (par[i].str != NULL)
	{
		ft_putstr(par[i].copy);
		ft_putchar('n');
		ft_putnbr(par[i].size_param);
		ft_putchar('n');
		j = 0;
		while (par[i].tab[j])
		{
			ft_putstr(par[i].tab[j]);
			ft_putchar('n');
			++j;
		}
		++i;
	}
}

OPEN FOR DISCUSSION

Quote
Share:

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. OK Read More