Skip to content

Commit

Permalink
implement exit_with_error
Browse files Browse the repository at this point in the history
  • Loading branch information
rask24 committed Jan 11, 2024
1 parent 5157ac8 commit f1e4d2d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ SRC_DIR = ./src
BUILD_DIR = ./build
INC_DIR = ./include
LIBFT_DIR = ./libft
SRC = $(SRC_DIR)/main.c
SRC = $(SRC_DIR)/main.c \
$(SRC_DIR)/utils/exit_with_error.c
OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC))
DEP = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.d, $(SRC))
DEPFLAGS = -MMD -MP
Expand Down
4 changes: 3 additions & 1 deletion include/push_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/10 12:37:54 by reasuke #+# #+# */
/* Updated: 2024/01/10 14:55:50 by reasuke ### ########.fr */
/* Updated: 2024/01/11 14:39:54 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -21,4 +21,6 @@

# include "../libft/libft.h"

void exit_with_error(void);

#endif
11 changes: 8 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/10 12:37:36 by reasuke #+# #+# */
/* Updated: 2024/01/10 14:59:00 by reasuke ### ########.fr */
/* Updated: 2024/01/11 14:42:21 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"

int main(void)
int main(int argc, char **argv)
{
printf("This is push_swap main file.\n");
if (argc < 2)
return (0);
// if (!is_valid_argument())
exit_with_error();
// TODO: delete
(void)argv;
return (0);
}
19 changes: 19 additions & 0 deletions src/utils/exit_with_error.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exit_with_error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/11 14:38:17 by reasuke #+# #+# */
/* Updated: 2024/01/11 14:38:59 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"

void exit_with_error(void)
{
ft_putendl_fd("Error", STDERR_FILENO);
exit(1);
}

0 comments on commit f1e4d2d

Please sign in to comment.