aboutsummaryrefslogtreecommitdiff
path: root/rush01_6x6_try/ex00/square.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-07-27 08:35:04 +0200
committerCharles <sircharlesaze@gmail.com>2019-07-27 08:35:04 +0200
commitf365ae69ad3923b5c565293d34c636d20991bd56 (patch)
treee6cd8039208c1da94e2e10a361cc65406a021195 /rush01_6x6_try/ex00/square.c
parente9170faaa55d0de82800751d063e3b05202ef808 (diff)
downloadpiscine-raw.tar.gz
piscine-raw.tar.bz2
piscine-raw.zip
adding bsq generator, remove rush01 6x6 tryraw
Diffstat (limited to 'rush01_6x6_try/ex00/square.c')
-rw-r--r--rush01_6x6_try/ex00/square.c134
1 files changed, 0 insertions, 134 deletions
diff --git a/rush01_6x6_try/ex00/square.c b/rush01_6x6_try/ex00/square.c
deleted file mode 100644
index 0260f73..0000000
--- a/rush01_6x6_try/ex00/square.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/* ************************************************************************** */
-/* */
-/* ::: :::::::: */
-/* helpers.c :+: :+: :+: */
-/* +:+ +:+ +:+ */
-/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
-/* +#+#+#+#+#+ +#+ */
-/* Created: 2019/07/13 12:31:20 by cacharle #+# #+# */
-/* Updated: 2019/07/14 13:26:55 by cacharle ### ########.fr */
-/* */
-/* ************************************************************************** */
-
-#include <stdlib.h>
-#include "include.h"
-
-/*
-** Parse the program's first argument where each row is in order
-** col up, col down, row left, row right
-*/
-
-t_views parse_arg(char *arg)
-{
- int i;
- int j;
- t_views views;
-
- views = init_square(4);
- views.size = 4;
- i = 0;
- j = 0;
- while (i < 16)
- {
- if (arg[i] == ' ')
- {
- arg++;
- continue;
- }
- views.self[j][i % 4] = arg[i] - '0';
- if (i % 4 == 3)
- j++;
- i++;
- }
- return (views);
-}
-
-/*
-** Allocate memory for a 2D array(square) of `size`
-** initialize each cell to 0.
-*/
-
-t_square init_square(int size)
-{
- int i;
- int j;
- t_square square;
-
- square.self = malloc(sizeof(int*) * size);
- square.size = size
- i = 0;
- while (i < size)
- {
- square.self[i] = malloc(sizeof(int) * size);
- j = 0;
- while (j < size)
- square.self[i][j++] = 0;
- i++;
- }
- return (square);
-}
-
-/*
-** Duplicate the square, create an empty clone
-** and copy each element of `square` in it.
-*/
-
-t_square dup_square(t_square square)
-{
- t_square clone;
- int i;
- int j;
-
- clone = init_square(4);
- i = 0;
- while (i < 4)
- {
- j = 0;
- while (j < 4)
- {
- clone.self[i][j] = square.self[i][j];
- j++;
- }
- i++;
- }
- return (clone);
-}
-
-/*
-** Free each row of the square and the square itself.
-*/
-
-void destroy_square(int **square)
-{
- int i;
-
- i = 0;
- while (i < 4)
- free(square.self[i++]);
- free(square.self);
-}
-
-/*
-** Print each row followed by a line break
-** and each element of the row but the last followed by a space.
-*/
-
-void print_square(t_square square)
-{
- int i;
- int j;
-
- i = 0;
- while (i < square.size)
- {
- j = 0;
- while (j < square.size)
- {
- ft_putnbr(square.self[i][j++]);
- if (j != 4)
- ft_putchar(' ');
- }
- ft_putchar('\n');
- i++;
- }
-}