diff options
start from scratch
1 files changed, 0 insertions, 37 deletions
| -rw-r--r-- | Binary_files/SaveStructsToBinaryFile(as array).cpp | 37 |
diff --git a/Binary_files/SaveStructsToBinaryFile(as array).cpp b/Binary_files/SaveStructsToBinaryFile(as array).cpp deleted file mode 100644 index 146a93c..0000000 --- a/Binary_files/SaveStructsToBinaryFile(as array).cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include <iostream> -#include <fstream> -using namespace std; - -struct test -{ - char ch; - int num; -}; - -int main() -{ - - test arr[] = { { 'a', 4 }, { 'b', 5 }, { 'c', 6 } }; - - ofstream outF("Structs.bat", ios::binary); - - if (!outF.is_open()) - { - cout << "Error while opening file" << endl; - return 1; - } - - outF.write((const char*)&arr, sizeof(arr)); - //можем директно да запазим масива във файла. Резултатът ще същия като от SaveStructToBinaryFile.cpp - - - if (!outF.good()) - { - cout << "Error occurred while writing the file"; - return 1; - } - - outF.close(); - - return 0; -}
\ No newline at end of file |
