Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
1 files changed, 6 insertions, 0 deletions
-rw-r--r--Sem. 03/simple_struct_binary.cpp6
diff --git a/Sem. 03/simple_struct_binary.cpp b/Sem. 03/simple_struct_binary.cpp
index 6ee16de..37a6315 100644
--- a/Sem. 03/simple_struct_binary.cpp
+++ b/Sem. 03/simple_struct_binary.cpp
@@ -16,6 +16,9 @@ int main()
{ //write
Test t = { true, 45 };
ofstream file("testObj.bat", ios::binary);
+
+ if (!file.open())
+ return -1;
file.write((char*)&t, sizeof(t));
}
@@ -23,6 +26,9 @@ int main()
{ //read
Test t;
ifstream file("testObj.bat", ios::binary);
+
+ if (!file.open())
+ return -1;
file.read((char*)&t, sizeof(t));
std::cout << t.b << " " << t.x << std::endl;