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