Website Summary Files Commits Branches @commit @diff @stats
path: root / BinaryFiles
diff options
context:
space:
mode:
diff --git a/BinaryFiles/BinaryFiles_Cheatsheet.pdf b/BinaryFiles/BinaryFiles_Cheatsheet.pdf
deleted file mode 100644
index 397177c..0000000
--- a/BinaryFiles/BinaryFiles_Cheatsheet.pdf
+++ /dev/null
Binary files differ
diff --git a/BinaryFiles/GetStructsFromBinaryFile.cpp b/BinaryFiles/GetStructsFromBinaryFile.cpp
deleted file mode 100644
index 2d91189..0000000
--- a/BinaryFiles/GetStructsFromBinaryFile.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <iostream>
-#include <fstream>
-using namespace std;
-
-struct test
-{
- char ch;
- int num;
-};
-
-int GetFileSize(ifstream& ifs)
-{
- ifs.seekg(0, std::ios::end); //отиваме в края на файла
- int size = ifs.tellg(); //запазваме коя е текущата позиция(тя всъщност е и размерът на файла)
- ifs.seekg(0, std::ios::beg); //връщаме се в началото на файла
- return size;
-//тази функция е хубаво да я извикваме преди да сме чели каквото и да е от файла, понеже ще се върнем в началото и ще загубим информация до къде сме стигнали с четенето
-}
-
-
-int main()
-{
- std::ifstream inF("Structs.bat", std::ios::binary);
-
- if (!inF.is_open())
- return false;
-
- int fileSize = GetFileSize(inF); // взимаме големината на файла
- int objectCount = fileSize / sizeof(test); // намираме броя на обектите записани във файла
-
- test* arr = new test[objectCount];
-
- inF.read((char*)arr, fileSize); //директно ги четем в масива
-
- if (!inF)
- {
- cout << "Error occurred while reading from the file";
- return 1;
- }
- inF.close();
-
- for (int i = 0; i < objectCount; i++)
- cout << arr[i].ch << " " << arr[i].num << endl;
- delete[] arr;
-
- return 0;
-} \ No newline at end of file
diff --git a/BinaryFiles/README.md b/BinaryFiles/README.md
deleted file mode 100644
index f740e9f..0000000
--- a/BinaryFiles/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# How does the binary file look like?
-The file after running **SaveStructsToBinaryFile.cpp** or **SaveStructsToBinaryFile(as array).cpp**
-
-![Image of the binary file after running the code](https://lh3.googleusercontent.com/NcLcTEemBj6dMkOFFjUPo2jyR_7vdrUkn0dHqx8TX1CYmtW-XZzSaDwAxscJz0m3EnniPL68ag "Binary file")
-
diff --git a/BinaryFiles/SaveAndReadStudents_BinaryFile.cpp b/BinaryFiles/SaveAndReadStudents_BinaryFile.cpp
deleted file mode 100644
index 0f600aa..0000000
--- a/BinaryFiles/SaveAndReadStudents_BinaryFile.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-void SaveStudent(const char* name, int fn, ofstream& f)
-{
- f.write((const char*)&fn, sizeof(int)); //sizeof(int) is 4
- int strLen = strlen(name);
- f.write((const char*)&strLen,sizeof(int));
- f.write(name, strLen);
-}
-void ReadStudent(ifstream& f)
-{
- int fn;
- f.read((char*)&fn, sizeof(int));
-
- int nameLen;
- f.read((char*)&nameLen, sizeof(int));
-
- char* name = new char[nameLen + 1];
- f.read(name, nameLen);
- name[nameLen] = '\0';
-
- cout << "Name: " << name << " Fn: " << fn << endl;
- delete[] name;
-
-}
-
-
-
-int main()
-{
- //ofstream f;
- // f.open("students.bat");
- // SaveStudent("Ivan",123,f);
- // SaveStudent("Sasho",555,f);
- // f.close();
-
- //ifstream f2;
- //f2.open("students.bat");
- //ReadStudent(f2);
- //ReadStudent(f2);
- //f2.close();
-
-
-
-}
diff --git a/BinaryFiles/SaveStructsToBinaryFile(as array).cpp b/BinaryFiles/SaveStructsToBinaryFile(as array).cpp
deleted file mode 100644
index b8d5cfe..0000000
--- a/BinaryFiles/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
diff --git a/BinaryFiles/SaveStructsToBinaryFile.cpp b/BinaryFiles/SaveStructsToBinaryFile.cpp
deleted file mode 100644
index 5e03b44..0000000
--- a/BinaryFiles/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
diff --git a/BinaryFiles/Structs.bat b/BinaryFiles/Structs.bat
deleted file mode 100644
index 37573c8..0000000
--- a/BinaryFiles/Structs.bat
+++ /dev/null
Binary files differ
diff --git a/BinaryFiles/StructsBAT (how does it look).png b/BinaryFiles/StructsBAT (how does it look).png
deleted file mode 100644
index 5e9e5b3..0000000
--- a/BinaryFiles/StructsBAT (how does it look).png
+++ /dev/null
Binary files differ