diff options
author | Simponic <loganhunt@simponic.xyz> | 2021-12-04 13:34:49 -0700 |
---|---|---|
committer | Simponic <loganhunt@simponic.xyz> | 2021-12-04 13:34:49 -0700 |
commit | aa1d7c6e284cc0818325614391619f3ff13d3e94 (patch) | |
tree | 8a59a6b3e5aacb7f682756d3c7751f1d72e1d940 /openmp/src/file.c | |
download | gol-aa1d7c6e284cc0818325614391619f3ff13d3e94.tar.gz gol-aa1d7c6e284cc0818325614391619f3ff13d3e94.zip |
Initial commit
Diffstat (limited to 'openmp/src/file.c')
-rw-r--r-- | openmp/src/file.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/openmp/src/file.c b/openmp/src/file.c new file mode 100644 index 0000000..3ecb613 --- /dev/null +++ b/openmp/src/file.c @@ -0,0 +1,17 @@ +#include "file.h" + +void read_in(char* filename, struct GAME* game) { + FILE* file = fopen(filename, "rb"); + for (int i = game->padding; i < game->height+game->padding; i++) { + fread(game->grid[i] + game->padding, sizeof(unsigned char), game->width, file); + } + fclose(file); +} + +void write_out(char* filename, struct GAME* game) { + FILE* file = fopen(filename, "w+"); + for (int i = game->padding; i < game->height+game->padding; i++) { + fwrite(game->grid[i] + game->padding, sizeof(unsigned char), game->width, file); + } + fclose(file); +} |