From f176299e4e49d85a81abac56be285357d23f0ff5 Mon Sep 17 00:00:00 2001 From: Angel Dimitriev Date: Tue, 15 Mar 2022 20:00:39 +0200 Subject: Delete array_of_students_write.cpp --- array_of_students_write.cpp | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 array_of_students_write.cpp (limited to 'array_of_students_write.cpp') diff --git a/array_of_students_write.cpp b/array_of_students_write.cpp deleted file mode 100644 index 3802bf8..0000000 --- a/array_of_students_write.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include -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)); -} - - -int main() -{ - Student* arr = new Student[4]; - initStudent(arr[0], "ivan", 44, 1234); - initStudent(arr[1], "petur", 12, 765); - initStudent(arr[2], "alex", 15, 44); - initStudent(arr[3], "katerina", 19, 12134); - - ofstream file("students.dat", ios::binary); - saveToFile(arr, 4, file); - - delete[] arr; -} \ No newline at end of file -- cgit v1.3.1-23-gd82d