Good evening! To study, I need to write an archive program that has a template structure by which the array is filled. Those. The structure contains questionnaire questions, and in the array, depending on its dimension, there will be such a number of completed questionnaires. According to the task, you also need to write a function that erases all data from the array. We were told to add a variable of type bool to the template structure, which is Zero if the item is empty and Unit if the item is filled. Those. resetting bool , we need to reset the contents of the array. However, it does not work out for me. The computer does not feel the connection between the value of the bool variable and the fullness of the array. Tell me, please, what is the error and how to fix it? Everything is commented out, I hope it will be easy to understand. Thank you very much for your help !!!
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> #include <conio.h> #include <cstdlib> typedef struct { char name[7]; int zach; bool FR; } anketa; FILE *fp; anketa mas[1]; void vvod(int, int); //----------- функция ввода void read_ff(int); void delet (int, int);//---------- функция очистки! int print_1(int); int print_all(int); int poisk_f(int, int); int main() { setlocale( LC_ALL,"Russian" ); setlocale( LC_ALL," "); char sim; int i=0; int kol; printf("Maximalnoe kol-vo anket?"); //---------кол-во анкет; размерность массива scanf("%d", &kol); for(int j=0; j<kol; j++) { mas[j].FR=0; //-----------------показываем,что когда массив пуст, FR равна нулю } printf("i=%d", i); for(;;) { printf("\n\4to budem delat??\n"); printf("v - vvod dannyh. Dobavit' odnu novuyu anketu ; \n"); printf("r - 4tenie. Vyvesti na ekran odnu anketu ; \n"); printf("R - vyvesti vse ankety ; \n"); printf("F - naity anketu ; \n"); printf("d - udalit vse ankety\n"); //--------------------ф-я меню Удалить sim = getch(); if(sim=='\n') sim = getch(); if (sim=='v') { vvod(i, kol); i++; } if (sim=='r') {printf ("\vvedite index elementa kotoryi hotite nape4atat"); scanf("%d", &i); print_1(i-1); } // -------распечатать if (sim=='R') {printf ("\n Vash Arhiv:\n"); print_all(kol); } if (sim=='F') { poisk_f(i, kol); } if (sim=='d') { delet(i, kol); //--------------ВЫЗЫВАЕМ ФУНКЦИЮ УДАЛИТЬ!! } if((sim!='R')&&(sim!='d')&&(sim!='r')&&(sim!='v')) {printf ("VVEDITE 4to-to drugoe\n"); } } system("PAUSE"); return 0; } //************ввод данных,заполнение одной анкеты-******** void vvod(int i, int kol) { printf("i=%d, kol=%d", i, kol); { if ((i<kol)&&(mas[i].FR!=1)) // ---------заполняем только тогда,когда индекс не превышает размерность и FR!=1 { printf ("\neiy? "); scanf("%s", &mas[i].name); printf ("\niiia? ca??oee? "); scanf ("%d", &mas[i].zach); fprintf(fp, "%s ", mas[i].name); fprintf(fp, "%d \n", mas[i].zach); read_ff(i); fclose(fp); mas[i].FR=1; //----------------заполнив одну анкету, приваиваем её FR начение 1, показывающее, что она заполнена i++; } else printf("\niao ianoa aey caiene. Auaa?eoa a?oao? iia?aoe?!\n "); } // ********************удаление. функция очистки******************* void delet (int i, int kol) { for(i=0; i<kol; i++) {mas[i].FR=0; //------------для всего массива делаем FR=0 } } void read_ff(int i) { fp=fopen("k.txt", "r"); for (i=0; i<3; i++) { fscanf (fp, "%s", &mas[i].name); fscanf (fp, "%d", &mas[i].zach); } fclose(fp); } int print_1(int k) { printf("eiy: %s, ", mas[k].name); printf("ca??oea: %d \n", mas[k].zach); } int print_all(int m) { for(int i=0; i<m; i++) { print_1(i); } } int poisk_f (int j, int kol) { char n[7]; printf("aaaaeoa eiy ?aeiaaea, aieaoo eioi?iai oioeoa iaeoe "); scanf("%s", n); for(j=0; j<kol; j++) {if (strstr(mas[j].name,n)!=NULL) { print_1(j); } else {printf ("ia iaeaaii ie iaiie caiene"); break; } } }