feat: add day 3

This commit is contained in:
2023-12-06 17:34:27 +01:00
parent b88ad0abf9
commit 52784ef81a
7 changed files with 316 additions and 14 deletions

View File

@@ -18,11 +18,12 @@ char* read_line(FILE *f, char **buffer, int *capacity) {
while(!feof(f)) {
char *res = fgets(*buffer + position, *capacity - position, f);
if(res[strlen(res) - 1] == '\n') {
(*buffer)[strlen(*buffer) - 1] = 0;
return *buffer;
}
*buffer = realloc(*buffer, 2 * sizeof (char) * *capacity);
position += (int) strlen(res);
position = (int) strlen(*buffer);
*capacity *= 2;
}