Website Summary Files Commits Branches @commit @diff @stats
path: root / Binary_files / SaveStructsToBinaryFile.cpp
diff options
context:
space:
mode:
Commit0218c678e13e1cb94a352c91733cea68467dc566 (patch)
Author
 Angeld55 <angel_dimitriev@abv.bg>
2021-02-14 23:06:35 +0200
Committer
 Angeld55 <angel_dimitriev@abv.bg>
2021-02-14 23:06:35 +0200
Files16fb3114cb560242458d10411765e50f5d6183db /Binary_files/SaveStructsToBinaryFile.cpp
Object-oriented_programming_FMI-0218c678e13e1cb94a352c91733cea68467dc566.tar
Object-oriented_programming_FMI-0218c678e13e1cb94a352c91733cea68467dc566.tar.gz
Object-oriented_programming_FMI-0218c678e13e1cb94a352c91733cea68467dc566.zip
Parentd4ae0ef9ec1b54420176c4a88e09f2fd44ae31b0 (diff)
start from scratch
1 files changed, 0 insertions, 40 deletions
-rw-r--r--Binary_files/SaveStructsToBinaryFile.cpp40
diff --git a/Binary_files/SaveStructsToBinaryFile.cpp b/Binary_files/SaveStructsToBinaryFile.cpp
deleted file mode 100644
index 3caad14..0000000
--- a/Binary_files/SaveStructsToBinaryFile.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <iostream>
-#include <fstream>
-using namespace std;
-
-struct test
-{
- char ch;
- int num;
-};
-
-int main()
-{
-
- test obj1{ 'a', 4 };
- test obj2{ 'b', 5 };
- test obj3{ 'c', 6 };
-
- ofstream outF("Structs.bat", ios::binary);
-
- if (!outF.is_open())
- {
- cout << "Error while opening file"<<endl;
- return 1;
- }
-
- //запазваме 3-те обекта във файла
- outF.write((const char*)&obj1, sizeof(test));
- outF.write((const char*)&obj2, sizeof(test));
- outF.write((const char*)&obj3, sizeof(test));
-
- if (!outF.good()) // проверяваме дали след операцията потокът е в невалидено състояние
- {
- cout<<"Error occurred while writing the file";
- return 1;
- }
-
- outF.close();
-
- return 0;
-} \ No newline at end of file