From a4fa83c7c14215d241229d9a29a9fb8852a587bc Mon Sep 17 00:00:00 2001 From: Angel Dimitriev Date: Wed, 9 Mar 2022 16:02:25 +0200 Subject: Rename static_struct_binary.cpp to simple_struct_binary.cpp --- Sem. 03/simple_struct_binary.cpp | 31 +++++++++++++++++++++++++++++++ Sem. 03/static_struct_binary.cpp | 31 ------------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 Sem. 03/simple_struct_binary.cpp delete mode 100644 Sem. 03/static_struct_binary.cpp diff --git a/Sem. 03/simple_struct_binary.cpp b/Sem. 03/simple_struct_binary.cpp new file mode 100644 index 0000000..6ee16de --- /dev/null +++ b/Sem. 03/simple_struct_binary.cpp @@ -0,0 +1,31 @@ +#include +#include +#pragma warning(disable:4996) +using namespace std; + + +struct Test +{ + bool b; + int x; +}; + +int main() +{ + + { //write + Test t = { true, 45 }; + ofstream file("testObj.bat", ios::binary); + + file.write((char*)&t, sizeof(t)); + } + + { //read + Test t; + ifstream file("testObj.bat", ios::binary); + + file.read((char*)&t, sizeof(t)); + std::cout << t.b << " " << t.x << std::endl; + } + +} diff --git a/Sem. 03/static_struct_binary.cpp b/Sem. 03/static_struct_binary.cpp deleted file mode 100644 index 6ee16de..0000000 --- a/Sem. 03/static_struct_binary.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#pragma warning(disable:4996) -using namespace std; - - -struct Test -{ - bool b; - int x; -}; - -int main() -{ - - { //write - Test t = { true, 45 }; - ofstream file("testObj.bat", ios::binary); - - file.write((char*)&t, sizeof(t)); - } - - { //read - Test t; - ifstream file("testObj.bat", ios::binary); - - file.read((char*)&t, sizeof(t)); - std::cout << t.b << " " << t.x << std::endl; - } - -} -- cgit v1.3.1-23-gd82d