From aa1d7c6e284cc0818325614391619f3ff13d3e94 Mon Sep 17 00:00:00 2001 From: Simponic Date: Sat, 4 Dec 2021 13:34:49 -0700 Subject: Initial commit --- openmp/src/create_grid.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 openmp/src/create_grid.c (limited to 'openmp/src/create_grid.c') diff --git a/openmp/src/create_grid.c b/openmp/src/create_grid.c new file mode 100644 index 0000000..d6a5b94 --- /dev/null +++ b/openmp/src/create_grid.c @@ -0,0 +1,38 @@ +#include "create_grid.h" + +void print_grid(struct GAME* game) { + printf("\n===GRID===\n"); + for (int y = 0; y < game->height; y++) { + for (int x = 0; x < game->width; x++) { + printf("%i ", game->grid[y][x]); + } + printf("\n"); + } +} + +void create_grid(int argc, char** argv) { + char* filename; + struct GAME game; + game.padding = 0; + if (argc == 5) { + game.width = atoi(argv[2]); + game.height = atoi(argv[3]); + filename = argv[4]; + } else { + printf("Usage: ./gol create-grid \n"); + exit(1); + } + + unsigned char** grid = malloc(sizeof(unsigned char*) * game.height); + for (int y = 0; y < game.height; y++) { + grid[y] = malloc(sizeof(unsigned char*) * game.width); + printf("Row %i: ", y); + for (int x = 0; x < game.width; x++) { + char temp; + scanf("%i%c", (unsigned int*)&grid[y][x],&temp); + } + } + game.grid = grid; + write_out(filename, &game); + print_grid(&game); +} -- cgit v1.2.3-70-g09d2