Ikd
This commit is contained in:
parent
948354d97a
commit
826f885936
27
ex00/main.c
27
ex00/main.c
|
@ -6,7 +6,7 @@
|
||||||
/* By: jtorrez- <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jtorrez- <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/03/18 20:15:26 by jtorrez- #+# #+# */
|
/* Created: 2023/03/18 20:15:26 by jtorrez- #+# #+# */
|
||||||
/* Updated: 2023/03/19 17:13:50 by tischmid ### ########.fr */
|
/* Updated: 2023/03/19 17:20:41 by tischmid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -17,10 +17,11 @@ void ft_putstr(char *str);
|
||||||
|
|
||||||
// Entry point of the program
|
// Entry point of the program
|
||||||
// Parses the program arguments and fails if the number of passed
|
// Parses the program arguments and fails if the number of passed
|
||||||
// arguments is not 2.
|
// arguments is not 2 or 0.
|
||||||
// Also fails if the passed arguments are out of
|
// Also fails if the passed arguments are out of
|
||||||
// bounds (200 for width, 100 for height).
|
// bounds (200 for width, 100 for height).
|
||||||
// argv[0] contains the path of the executable, eg ./rush00
|
// argv[0] contains the path of the executable, eg ./rush00
|
||||||
|
#include <stdio.h>
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int width;
|
int width;
|
||||||
|
@ -31,21 +32,21 @@ int main(int argc, char *argv[])
|
||||||
ft_putstr("Usage: ");
|
ft_putstr("Usage: ");
|
||||||
ft_putstr(argv[0]);
|
ft_putstr(argv[0]);
|
||||||
ft_putstr(" [WIDTH HEIGHT]\n");
|
ft_putstr(" [WIDTH HEIGHT]\n");
|
||||||
return (1);
|
|
||||||
}
|
}
|
||||||
width = ft_atoi(argv[1]);
|
if (argc == 1)
|
||||||
height = ft_atoi(argv[2]);
|
{
|
||||||
|
width = ft_atoi(argv[1]);
|
||||||
|
height = ft_atoi(argv[2]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
width = 5;
|
||||||
|
height = 3;
|
||||||
if (width >= 200)
|
if (width >= 200)
|
||||||
{
|
|
||||||
ft_putstr("Width must be less than 200\n");
|
ft_putstr("Width must be less than 200\n");
|
||||||
return (2);
|
else if (height >= 100)
|
||||||
}
|
|
||||||
if (height >= 100)
|
|
||||||
{
|
|
||||||
ft_putstr("Height must be less than 100\n");
|
ft_putstr("Height must be less than 100\n");
|
||||||
return (3);
|
else
|
||||||
}
|
rush(width, height);
|
||||||
rush(width, height);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue