Compare commits

...

6 Commits

Author SHA1 Message Date
Timo Schmidt 718c214400 .gitignore 2023-03-26 07:52:22 +02:00
Timo Schmidt 5c9a137b90 Includedir 2023-03-26 07:51:40 +02:00
Timo Schmidt e4128afd05 config.mk 2023-03-26 07:51:29 +02:00
Timo Schmidt 64ca327e50 Makefile 2023-03-26 07:51:24 +02:00
Timo Schmidt 1458dfab52 Amend print_array.c 2023-03-26 07:51:15 +02:00
Timo Schmidt a61387a07e remove stdio.h header 2023-03-26 07:50:56 +02:00
7 changed files with 126 additions and 16 deletions

2
ex00/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
obj/
build/

41
ex00/Makefile Normal file
View File

@ -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

33
ex00/config.mk Normal file
View File

@ -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))

View File

@ -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

21
ex00/include/main.h Normal file
View File

@ -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

View File

@ -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"

View File

@ -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);
}