Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
1 files changed, 9 insertions, 1 deletions
-rw-r--r--Sem. 03/array_of_students_write.cpp10
diff --git a/Sem. 03/array_of_students_write.cpp b/Sem. 03/array_of_students_write.cpp
index 3802bf8..c356a28 100644
--- a/Sem. 03/array_of_students_write.cpp
+++ b/Sem. 03/array_of_students_write.cpp
@@ -32,7 +32,15 @@ int main()
initStudent(arr[3], "katerina", 19, 12134);
ofstream file("students.dat", ios::binary);
+
+ if(!file.is_open())
+ {
+ std::cout << "Error while opening the file!" << std::endl;
+ delete[] arr; //!
+ return -1;
+ }
+
saveToFile(arr, 4, file);
delete[] arr;
-} \ No newline at end of file
+}