Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<conio.h>
- typedef struct { char nume[30];
- char an;
- int grupa;
- char nrdiscipline;
- char note[15];
- } STUDENT;
- void main ()
- {
- FILE *f;
- STUDENT s;
- char nume_f[20];
- int i;
- printf("Nume fisier binar: ");
- fflush(stdin); gets(nume_f);
- f= fopen(nume_f,"r+b");
- // testarea daca s-a deschis fisierul
- if (!f)
- printf("Fisierul nu a putut fi deschis");
- else
- {
- fseek(f,0,SEEK_END);
- printf("Nume si prenume Student:");fflush(stdin);gets(s.nume);
- while (!feof(stdin))
- {
- printf("An studiu: ");scanf("%d",&s.an);
- printf("Grupa: ");scanf("%d",&s.grupa);
- printf("Nr discipline: ");scanf("%d",&s.nrdiscipline);
- for (i=0;i<s.nrdiscipline;i++)
- {printf("Nota %d= ",i+1);scanf("%d",&s.note[i]);}
- fwrite(&s,sizeof(STUDENT),1,f);
- printf("Nume si prenume Student:");fflush(stdin);gets(s.nume);
- }
- fclose(f);
- }
- printf("\n Adaugarea s-a terminat");
- printf("\Apasa o tasta");
- _getch();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement