From b593f88fb5ca9142eccee7c755367109159626ad Mon Sep 17 00:00:00 2001 From: Angel Dimitriev Date: Wed, 11 May 2022 09:55:31 -0400 Subject: Update task3_not_done.cpp --- Sem. 02/task3_not_done.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sem. 02/task3_not_done.cpp b/Sem. 02/task3_not_done.cpp index 0389268..29727b1 100644 --- a/Sem. 02/task3_not_done.cpp +++ b/Sem. 02/task3_not_done.cpp @@ -102,7 +102,7 @@ void initStudentCollection(StudentCollection& collection, const char* fileName) { ifstream file(fileName); - if (studentsCount == 0 || !file.is_open()) + if (!file.is_open()) { cout << "Error while reading from file!" << std::endl; collection.studentsCount = 0; @@ -111,10 +111,15 @@ void initStudentCollection(StudentCollection& collection, const char* fileName) return; } - size_t linesCount = getLinesCount(fileName); + size_t linesCount = getLinesCount(file); size_t studentsCount = linesCount - 1; + if(studentsCount == 0) + { + return; + } + collection.data = new StudentRecord[studentsCount]; collection.studentsCount = studentsCount; -- cgit v1.3.1-23-gd82d