Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitb593f88fb5ca9142eccee7c755367109159626ad (patch)
Author
 Angel Dimitriev <angel_dimitriev@abv.bg>
2022-05-11 09:55:31 -0400
Committer
 GitHub <noreply@github.com>
2022-05-11 09:55:31 -0400
Filesed661c482f3c818c2a23e5e8a786b9b3c6c9add7
Object-oriented_programming_FMI-b593f88fb5ca9142eccee7c755367109159626ad.tar
Object-oriented_programming_FMI-b593f88fb5ca9142eccee7c755367109159626ad.tar.gz
Object-oriented_programming_FMI-b593f88fb5ca9142eccee7c755367109159626ad.zip
Parent6f3051e2f5fe34de52b9e98c60128d18257a3b30 (diff)
Update task3_not_done.cpp
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;