diff options
Update students_dynamicName_to_binary.cpp
1 files changed, 14 insertions, 0 deletions
| -rw-r--r-- | Sem. 03/students_dynamicName_to_binary.cpp | 14 |
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); |
