mirror of
https://github.com/LucasCodeur/alcu.git
synced 2026-04-28 17:44:34 +02:00
print_board
This commit is contained in:
@@ -25,7 +25,8 @@ P_LIBFT = libft/
|
|||||||
SRC = main.c \
|
SRC = main.c \
|
||||||
get_next_line.c \
|
get_next_line.c \
|
||||||
fill_array.c \
|
fill_array.c \
|
||||||
check_input.c
|
check_input.c \
|
||||||
|
print_board.c
|
||||||
|
|
||||||
SRCS = $(addprefix $(P_SRC), $(SRC))
|
SRCS = $(addprefix $(P_SRC), $(SRC))
|
||||||
OBJS = $(patsubst $(P_SRC)%.c,$(P_OBJ)%.o,$(SRCS))
|
OBJS = $(patsubst $(P_SRC)%.c,$(P_OBJ)%.o,$(SRCS))
|
||||||
|
|||||||
+4
-1
@@ -11,9 +11,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef ALCU_H
|
#ifndef ALCU_H
|
||||||
# define ALCU_H
|
#define ALCU_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
char *read_file(int fd);
|
char *read_file(int fd);
|
||||||
int check_input(int fd);
|
int check_input(int fd);
|
||||||
|
void print_board(int *game_state, size_t nb_line);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ int main(int argc, char *argv[]) {
|
|||||||
ft_putstr_fd("ERROR", 2);
|
ft_putstr_fd("ERROR", 2);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
int test[] = {8, 5, 3, 2, 1};
|
||||||
|
print_board(test, 5);
|
||||||
return (0);
|
return (0);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* print_board.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/28 16:06:30 by dgaillet #+# #+# */
|
||||||
|
/* Updated: 2026/03/28 16:06:32 by dgaillet ### ########lyon.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "alcu.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
void print_board(int *game_state, size_t nb_line) {
|
||||||
|
int size_of_first;
|
||||||
|
size_t i;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
i = -1;
|
||||||
|
size_of_first = game_state[0];
|
||||||
|
while (++i < nb_line) {
|
||||||
|
j = -1;
|
||||||
|
while (++j < size_of_first - game_state[i])
|
||||||
|
write(1, " ", 1);
|
||||||
|
j = -1;
|
||||||
|
while (++j < game_state[i]) {
|
||||||
|
write(1, "|", 1);
|
||||||
|
if (j < game_state[i] - 1)
|
||||||
|
write(1, " ", 1);
|
||||||
|
}
|
||||||
|
j = -1;
|
||||||
|
while (++j < size_of_first - game_state[i])
|
||||||
|
write(1, " ", 1);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user