Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitde2a38177a94ae3f2a0b02bd544187346b9a2b5b (patch)
Author
 Angel Dimitriev <angel_dimitriev@abv.bg>
2022-03-10 01:05:38 +0200
Committer
 GitHub <noreply@github.com>
2022-03-10 01:05:38 +0200
Filesd3bc68db6f08c843d48a18b0a86df15c9f6f102c
Object-oriented_programming_FMI-de2a38177a94ae3f2a0b02bd544187346b9a2b5b.tar
Object-oriented_programming_FMI-de2a38177a94ae3f2a0b02bd544187346b9a2b5b.tar.gz
Object-oriented_programming_FMI-de2a38177a94ae3f2a0b02bd544187346b9a2b5b.zip
Parentcb2b000a599570542de4d6ab59a1b78900ce0463 (diff)
Update students_staticName_to_binary.cpp
1 files changed, 8 insertions, 10 deletions
-rw-r--r--Sem. 03/students_staticName_to_binary.cpp18
diff --git a/Sem. 03/students_staticName_to_binary.cpp b/Sem. 03/students_staticName_to_binary.cpp
index 5c9c77d..51fb711 100644
--- a/Sem. 03/students_staticName_to_binary.cpp
+++ b/Sem. 03/students_staticName_to_binary.cpp
@@ -23,11 +23,10 @@ int main()
ofstream file("student.dat", ios::binary);
if (!file.open())
- {
- cout << "Error while writing to binary file!" << endl;
- delete[] s1.name, s2.name;
- return -1;
- }
+ {
+ cout << "Error while writing to binary file!" << endl;
+ return -1;
+ }
file.write((const char*)&st, sizeof(st)); //since the data is grouped in the struct, we can save it like this.
}
@@ -37,11 +36,10 @@ int main()
ifstream file("student.dat", ios::binary);
if (!file.open())
- {
- cout << "Error while reading from binary file!" << endl;
- delete[] s1.name, s2.name;
- return -1;
- }
+ {
+ cout << "Error while reading from binary file!" << endl;
+ return -1;
+ }
file.read((char*)&st, sizeof(st));