From 5742f90fdcbeda996e2dd69c5c3da2da99c44a41 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Mon, 2 Dec 2024 20:55:38 +0100 Subject: list_find: changed while loop --- FICS/lists.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/FICS/lists.c b/FICS/lists.c index 5f93baf..c76e645 100644 --- a/FICS/lists.c +++ b/FICS/lists.c @@ -89,11 +89,9 @@ list_find(int p, enum ListWhich l) rfree(tempList); return NULL; } - while (!feof(fp)) { - if (fgets(listmember, 100, fp) != NULL) { - listmember[strlen(listmember) - 1] = '\0'; - tempList->member[count++] = xstrdup(listmember); - } + while (fgets(listmember, ARRAY_SIZE(listmember), fp) != NULL) { + listmember[strcspn(listmember, "\n")] = '\0'; + tempList->member[count++] = xstrdup(listmember); } fclose(fp); -- cgit v1.2.3