diff --git a/src/c/main.c b/src/c/main.c index 971f88e..5d72793 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -69,20 +69,8 @@ int main() void printInit() { FILE *stream; - char *line = NULL; - size_t len = 0; - ssize_t read; - stream = getStream(gameInstructionsFile); - - /* print line by line from file */ - while ((read = getline(&line, &len, stream)) != -1) - { - // printf("Retrieved line of length %u :\n", read); - printf("%s", line); - } - - free(line); /* Deallocate allocated memory */ + printStreamLines(stream); fclose(stream); /* closing file */ acceptInstructions(); diff --git a/src/c/nav_helper.c b/src/c/nav_helper.c index 78bdeb7..5a2d670 100644 --- a/src/c/nav_helper.c +++ b/src/c/nav_helper.c @@ -25,3 +25,19 @@ FILE *getStream(char *filePath) return stream; } + +void printStreamLines(FILE *stream){ + + char *line = NULL; + size_t len = 0; + ssize_t read; + + /* print line by line from file */ + while ((read = getline(&line, &len, stream)) != -1) + { + // printf("Retrieved line of length %u :\n", read); + printf("%s", line); + } + + free(line); /* Deallocate allocated memory */ +} diff --git a/src/c/nav_helper.h b/src/c/nav_helper.h index f90f1c2..056a4f1 100644 --- a/src/c/nav_helper.h +++ b/src/c/nav_helper.h @@ -8,5 +8,6 @@ bool startsWith(const char *a, const char *b); FILE *getStream(char *filePath); +void printStreamLines(FILE *stream); #endif \ No newline at end of file