Day 2 mid

This commit is contained in:
benjamyn committed 2023-12-04 11:57:07 +11:00
1 parent ea13817511
commit 16eddd406d
2 files changed
+12 -4

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
{
"files.associations": {
"stdlib.h": "c"
}
}
+7 -4
View File
@@ -7,6 +7,8 @@
#include <sys/mman.h>
#include <sys/stat.h>
int ID_OFFSET;
struct Game
{
int red;
@@ -22,7 +24,7 @@ struct Games
void parse_game_data(char *line, struct Games games)
{
printf("%s", line);
printf("%s\n", line);
struct Game tmpGame;
}
@@ -46,6 +48,7 @@ int get_id(char *ptr)
}
else
{
ID_OFFSET = i;
break;
}
}
@@ -98,12 +101,13 @@ int main()
inLine = 1;
i += GAME_OFFSET;
id = get_id(&ptr[i]);
i += ID_OFFSET + 2;
continue;
}
if (ptr[i + j] == '\n')
{
memcpy(tmpLine, &ptr[i], j);
printf("ID: %i |", id);
parse_game_data(tmpLine, games);
i++;
i += j;
@@ -114,7 +118,6 @@ int main()
}
inLine = 0;
exit(0);
}
err = munmap(ptr, statbuf.st_size);
@@ -125,4 +128,4 @@ int main()
}
return 0;
}
}