Compare commits
6 Commits
c0ba167a60
...
718c214400
| Author | SHA1 | Date |
|---|---|---|
|
|
718c214400 | |
|
|
5c9a137b90 | |
|
|
e4128afd05 | |
|
|
64ca327e50 | |
|
|
1458dfab52 | |
|
|
a61387a07e |
|
|
@ -0,0 +1,2 @@
|
|||
obj/
|
||||
build/
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
# Makefile for rush01
|
||||
|
||||
include config.mk
|
||||
|
||||
NAME?=rush-01
|
||||
|
||||
SRC=gen_util.c handle_input.c handle_mem.c main.c print_array.c
|
||||
HEADERS=
|
||||
|
||||
_OBJ=$(SRC:.c=.o)
|
||||
OBJ=$(patsubst %,$(OBJDIR)/%,$(_OBJ))
|
||||
DEPS=$(patsubst %,$(INCDIR)/%,$(HEADERS))
|
||||
|
||||
.PHONY: clean install uninstall fclean all re
|
||||
|
||||
all: $(BUILDDIR)/$(NAME)
|
||||
|
||||
$(BUILDDIR)/$(NAME): $(OBJ)
|
||||
$(CC) $(LDFLAGS) -o $@ $^
|
||||
|
||||
$(OBJDIR)/%.o: %.c $(DEPS)
|
||||
norminette $<
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
$(RM) $(wildcard $(OBJDIR)/$(OBJ))
|
||||
$(RM) $(wildcard $(INCDIR)/*~)
|
||||
$(RM) $(wildcard *~)
|
||||
|
||||
fclean: clean
|
||||
$(RM) $(wildcard $(BUILDDIR)/*)
|
||||
|
||||
install: all
|
||||
$(MKDIR) $(DESTDIR)$(PREFIX)/bin
|
||||
$(CP) $(BUILDDIR)/$(NAME) $(DESTDIR)$(PREFIX)/bin
|
||||
$(CHMOD) 755 $(DESTDIR)$(PREFIX)/bin/$(NAME)
|
||||
|
||||
uninstall:
|
||||
$(RM) $(DESTDIR)$(PREFIX)/bin/$(NAME)
|
||||
|
||||
re: fclean all
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
# Configuration for rush01's Makefile
|
||||
|
||||
# paths
|
||||
PREFIX=~/.local
|
||||
INCDIR=include
|
||||
OBJDIR=obj
|
||||
BUILDDIR=build
|
||||
DIRS=
|
||||
DIRS+=${INCDIR}
|
||||
DIRS+=${OBJDIR}
|
||||
DIRS+=${BUILDDIR}
|
||||
|
||||
# includes
|
||||
INCS=-I${INCDIR}
|
||||
|
||||
# flags
|
||||
CFLAGS=
|
||||
CFLAGS+=-Wall
|
||||
CFLAGS+=-Wextra
|
||||
#CFLAGS+=-Werror
|
||||
CFLAGS+=${INCS}
|
||||
LDFLAGS=
|
||||
|
||||
# compiler and linker
|
||||
CC=cc
|
||||
|
||||
# other executables
|
||||
RM=/bin/rm -f
|
||||
MKDIR=/bin/mkdir -p
|
||||
CP=/bin/cp -f
|
||||
CHMOD=/bin/chmod
|
||||
|
||||
$(shell mkdir -p $(DIRS))
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* handle_input.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/26 07:48:00 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/26 07:48:15 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef HANDLE_INPUT_H
|
||||
# define HANDLE_INPUT_H
|
||||
|
||||
int check_inp_valid(int argc, char **argv, int n);
|
||||
int str_len(char *str);
|
||||
void atoi_arr(char **argv, int *borders, int n);
|
||||
int check_opposite_sum(int *borders, int n);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/26 07:43:49 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/26 07:44:09 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MAIN_H
|
||||
# define MAIN_H
|
||||
|
||||
int **allo_mem(int **board, int n);
|
||||
void free_mem(int *borders, int **board, int n);
|
||||
int handle_input(int argc, char **argv, int *borders, int n);
|
||||
void put_error(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -6,12 +6,11 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/26 06:13:07 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/26 07:44:16 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/26 07:49:42 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "include/main.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: akarami <akarami@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/25 17:15:08 by akarami #+# #+# */
|
||||
/* Updated: 2023/03/26 06:11:37 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/26 07:48:42 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ void ft_putchar(char c)
|
|||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
void ft_print_arrays(int arr_matrix, int size)
|
||||
void ft_print_arrays(int **board, int size)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
|
@ -28,21 +28,14 @@ void ft_print_arrays(int arr_matrix, int size)
|
|||
y = 1;
|
||||
while (y <= size)
|
||||
{
|
||||
ft_putchar(arr_matrix[x][y] + '0');
|
||||
ft_putchar(board[x][y]);
|
||||
if (y != size)
|
||||
{
|
||||
ft_putchar('');
|
||||
ft_putchar(' ');
|
||||
}
|
||||
y++;
|
||||
++y;
|
||||
}
|
||||
x++;
|
||||
ft_putchar('\n');
|
||||
++x;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
int arr_matrix;
|
||||
int size;
|
||||
|
||||
ft_print_arrays(arr_matrix, size);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue