Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 02 / task3_not_done.cpp
diff options
context:
space:
mode:
1 files changed, 7 insertions, 2 deletions
-rw-r--r--Sem. 02/task3_not_done.cpp9
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;