There is a structure:

struct student { char name[50], gr[8], birth[11]; int num, hist, math, prog; char skip[4]; }; 

I tried, nothing happened (I tried to create a new file and then rename it to the old one), I was completely confused:

 void del_skip(const char* name) { student z; FILE* f; FILE* temp; const char* t = "temp.txt"; int k = number_of_records1(name); f = fopen(name, "rb"); student* b = new student[k]; while (fread(&z, sizeof(student), 1, f)) { for (int i = 0; i < k; i++) { if (strcmp(z.skip, "NO")==0) b[i] = z; } } temp = fopen(t, "wb"); int k1 = sizeof(b) / sizeof(b[0]); for (int i = 0; i <= k1; i++) { fwrite(&b, sizeof(student), 1, temp); } fclose(f); remove(name); //f = fopen(name, "wb"); fclose(f); //while (fread(&b,sizeof(student),1,temp)) //{ // fwrite(&b, sizeof(student), 1, f); //} rename(t, name); fclose(temp); } 
  • sizeof(b) - this trick will not work with a dynamic array. Use the variable that is responsible for the size of the array ( k ) - acade

0