There is a program in which fields are entered for each structure from the array, then the entire array is written to a binary file, the question is how to implement the reverse program, that is, to open this file and create a new array from the structures.
#include "stdafx.h" #include<iostream> using namespace std; struct contact { char sname[50]; char number[11]; char adress[50]; }; const int m = 2; int _tmain(int argc, _TCHAR* argv[]) { contact a[m]; for (int i = 0; i < m; i++) { cin >> a[i].sname; cin >> a[i].number; cin >> a[i].adress; } FILE *f; f = fopen("input.dot", "wb"); fwrite(a, sizeof(contact), m, f); fclose(f); system("pause"); return 0; }