Production ready

This commit is contained in:
Juan Bosco Torrez Castillo 2023-03-18 20:24:08 +01:00
parent ca46c9f95e
commit b5c71a6b2c
2 changed files with 7 additions and 69 deletions

47
main.c
View File

@ -3,17 +3,14 @@
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* By: jtorrez- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/18 02:09:32 by tischmid #+# #+# */
/* Updated: 2023/03/18 04:52:15 by tischmid ### ########.fr */
/* Created: 2023/03/18 20:15:26 by jtorrez- #+# #+# */
/* Updated: 2023/03/18 20:21:42 by jtorrez- ### ########.fr */
/* */
/* ************************************************************************** */
void rush(int x, int y);
void ft_putchar(char c);
void ft_putstr(char *str);
void ft_putnbr(int nb);
int ft_atoi(char *str);
int main(int argc, char *argv[])
@ -22,51 +19,13 @@ int main(int argc, char *argv[])
int height;
if (argc != 3)
{
ft_putstr("\033[31mWrong number of arguments (expected 2 got ");
ft_putnbr(argc - 1);
ft_putstr(")\033[m\n");
ft_putstr("\033[32mUsage: ./rush00 [width] [height]\033[m\n");
return (1);
}
width = ft_atoi(argv[1]);
height = ft_atoi(argv[2]);
rush(width, height);
return (0);
}
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i] != 0)
ft_putchar(str[i++]);
}
void ft_putnbr(int nb)
{
char last_digit;
if (nb < 0)
{
ft_putchar('-');
if (nb == 1 << 31)
{
nb += 2e9;
ft_putchar('2');
}
nb *= -1;
}
last_digit = nb % 10 + '0';
if (nb > 9)
{
nb /= 10;
ft_putnbr(nb);
}
ft_putchar(last_digit);
}
int ft_atoi(char *str)
{
int i;

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush0X.c :+: :+: :+: */
/* rush00.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* By: jtorrez- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/18 02:10:24 by tischmid #+# #+# */
/* Updated: 2023/03/18 19:48:04 by jtorrez- ### ########.fr */
/* Created: 2023/03/18 20:15:12 by jtorrez- #+# #+# */
/* Updated: 2023/03/18 20:15:17 by jtorrez- ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,32 +15,11 @@ void horiz_line(char left, char middle, char right, int width);
const char g_inside = ' ';
// Rush 00
// clockwise, starting from top left
const char g_corners[] = {'o', 'o', 'o', 'o', '\0'};
const char g_horizontal = '-';
const char g_vertical = '|';
// Rush 01
// const char g_corners[] = {'/', '\\', '/', '\\', '\0'};
// const char g_horizontal = '*';
// const char g_vertical = '*';
// Rush 02
// const char g_corners[] = {'A', 'A', 'C', 'C', '\0'};
// const char g_horizontal = 'B';
// const char g_vertical = 'B';
// Rush 03
// const char g_corners[] = {'A', 'C', 'C', 'A', '\0'};
// const char g_horizontal = 'B';
// const char g_vertical = 'B';
// Rush 04
// const char g_corners[] = {'A', 'C', 'A', 'C', '\0'};
// const char g_horizontal = 'B';
// const char g_vertical = 'B';
void rush(int x, int y)
{
int i;