ADDED testtg.c Index: testtg.c ================================================================== --- /dev/null +++ testtg.c @@ -0,0 +1,26 @@ +#include +#include +#include + +#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); +}