From 2815c44224cdb99695248faadce10b1737f7c766 Mon Sep 17 00:00:00 2001 From: Oskar Date: Fri, 27 Oct 2023 23:04:22 +0200 Subject: Minor changes to GET_LINE() , also did a little test to check if it worked like it should. Seems to be working... --- functions.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'functions.c') diff --git a/functions.c b/functions.c index f2ce52e..324dd42 100644 --- a/functions.c +++ b/functions.c @@ -123,6 +123,16 @@ void shuffle(char arr[], int n) { int GET_LINE(char filename[], long focus, char **line) { // Making this function was hell. Hardest thing ive coded in a while. + size_t lines; + int ret = COUNT_LINES_IN_FILE(filename, &lines); + if (ret == 1) { + return EXIT_FAILURE; + } + + if ((long)lines < focus) { + return EXIT_FAILURE; + } + FILE *file; file = fopen(filename,"r"); // Open file -- cgit v1.2.3