From 684c5cd5357ee093c163b31406c8184f00452db6 Mon Sep 17 00:00:00 2001 From: Angel Dimitriev Date: Thu, 10 Mar 2022 01:03:14 +0200 Subject: Update students_dynamicName_to_binary.cpp --- Sem. 03/students_dynamicName_to_binary.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Sem. 03/students_dynamicName_to_binary.cpp b/Sem. 03/students_dynamicName_to_binary.cpp index f2f20dd..d35907f 100644 --- a/Sem. 03/students_dynamicName_to_binary.cpp +++ b/Sem. 03/students_dynamicName_to_binary.cpp @@ -52,6 +52,13 @@ int main() s2.age = 50; ofstream file("Students.dat", ios::binary); + + if (!file.open()) + { + cout << "Error while writing to binary file!" << endl; + return -1; + } + saveStudent(file, s1); saveStudent(file, s2); @@ -60,6 +67,13 @@ int main() { ifstream file("Students.dat", ios::binary); + + if (!file.open()) + { + cout << "Error while reading from file!" << endl; + return -1; + } + Student s1, s2; loadStudent(file, s1); -- cgit v1.3.1-23-gd82d