Advent of Code

testtg.c at [85a490fa64]
Login

testtg.c at [85a490fa64]

File testtg.c artifact d61466e43e part of check-in 85a490fa64


#include <stdbool.h>
#include <stdio.h>
#include <string.h>

#include "aocutils.h"

int main(void) {
    char *input = NULL;
    size_t ilen = slurp(&input, "test.txt");

    struct TextGrid tg;
    tg.data = input;
    tg.cols = strchr(input, '\n') - input + 1;
    tg.rows = tg.cols - 1; // rows includes the '\n'

    if (*TGcharptr(&tg, 11, 11) == '.') puts("1");
    if (TGcharptr(&tg, 12, 11) == NULL) puts("2");
    if (TGcharptr(&tg, 11, 12) == NULL) puts("3");
    if (*TGcharptr(&tg, 11, 12) == '\n') puts("33");
    if (TGcharptr(&tg, -1, -2) == NULL) puts("4");

    for (int k = 0; k < 12; k++) {
        *TGcharptr(&tg, k, k) = '#';
    }
    printf("\n\n%s\n", tg.data);
}