Day 2 mid
This commit is contained in:
parent
ea13817511
commit
16eddd406d
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"stdlib.h": "c"
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user