Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void search(FILE *g)
- {
- FILE *f;
- char ch;
- printf("Введите букву: ");
- gets(&ch);
- gets(&ch);
- ST stud, stud1[20], stud2[20];
- int num1 = 0, num2 = 0;
- if ((f = fopen("f.dat", "rb")) == NULL)
- printf("Ошибка доступа к файлу");
- else {
- printf("\n|-----------------------------------------------------|\n");
- while(fread(&stud, sizeof(ST), 1, f))
- {
- if (stud.N[0] == ch) {
- stud1[num1] = stud;
- num1++;
- }
- else {
- stud2[num2] = stud;
- num2++;
- }
- //printf("%12s %8s-%4d-%6f\n", stud.N, stud.GR, (stud.year), (stud.TT));
- }
- printf("Студенты:\n");
- for (int i = 0; i < num1; i++)
- printf("%s %s %d %f\n", stud1[i].N, stud1[i].GR, (stud1[i].year), (stud1[i].TT));
- fclose(f);
- f = fopen("f.dat", "wb");
- for (int i = 0; i < num2; i++)
- fwrite(&stud2[i], sizeof(ST), 1, f);
- for (int i = 0; i < num1; i++)
- fwrite(&stud1[i], sizeof(ST), 1, f);
- fclose(f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement