Website Summary Files Commits Branches @commit @diff @stats
path: root / array_of_students_read.cpp
diff options
context:
space:
mode:
Commitc52bfa065e309bfe204dd15c46d9176bcf5e1606 (patch)
Author
 Angel Dimitriev <angel_dimitriev@abv.bg>
2022-03-15 20:00:47 +0200
Committer
 GitHub <noreply@github.com>
2022-03-15 20:00:47 +0200
Filesfe9232332ca0d2757157c465832af8923dd9b2aa /array_of_students_read.cpp
Object-oriented_programming_FMI-c52bfa065e309bfe204dd15c46d9176bcf5e1606.tar
Object-oriented_programming_FMI-c52bfa065e309bfe204dd15c46d9176bcf5e1606.tar.gz
Object-oriented_programming_FMI-c52bfa065e309bfe204dd15c46d9176bcf5e1606.zip
Parentf176299e4e49d85a81abac56be285357d23f0ff5 (diff)
Delete array_of_students_read.cpp
1 files changed, 0 insertions, 56 deletions
-rw-r--r--array_of_students_read.cpp56
diff --git a/array_of_students_read.cpp b/array_of_students_read.cpp
deleted file mode 100644
index ab1f425..0000000
--- a/array_of_students_read.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#include <iostream>
-#include <fstream>
-#include <cstring>
-using namespace std;
-
-struct Student
-{
- char name[30];
- int age;
- int fn;
-};
-
-void initStudent(Student& st, const char* name, int age, int fn)
-{
- strcpy(st.name, name);
- st.age = age;
- st.fn = fn;
-}
-
-void saveToFile(const Student* students, size_t count, ofstream& file)
-{
- file.write((const char*)students, count * sizeof(Student));
-}
-
-
-size_t getFileSize(ifstream& f)
-{
- size_t currentPos = f.tellg();
- f.seekg(0, ios::end);
- size_t size = f.tellg();
-
- f.seekg(currentPos);
- return size;
-}
-
-void readFromFile(Student*& ptr, size_t& studentsCount, ifstream& f)
-{
- size_t sizeOfFile = getFileSize(f);
- studentsCount = sizeOfFile / sizeof(Student);
- ptr = new Student[studentsCount];
- f.read((char*)ptr, sizeOfFile);
-}
-
-
-int main()
-{
- Student* arr;
- size_t count;
- ifstream file("students.dat");
- readFromFile(arr, count, file);
-
- for (int i = 0; i < count; i++)
- std::cout << "Name: " << arr[i].name << ", age: " << arr[i].age << ", fn: " << arr[i].fn << std::endl;
-
- delete[] arr;
-} \ No newline at end of file