Skip to content

Instantly share code, notes, and snippets.

@paunstefan paunstefan/creare_fisier.c
Last active Apr 20, 2017

What would you like to do?
// Creeaza fisierul binar
typedef struct{
unsigned int an;
unsigned char luna;
unsigned char zi;
typedef struct{
char nume[20];
char cnp[14];
unsigned int nrm;
char fac[6];
unsigned char an;
unsigned int grupa;
char s;
char spec[11];
char note[20];
void main()
FILE* f;
char numef[20];
int i;
printf("Nume fisier: "); gets(numef);
f = fopen(numef, "wb");
if (!f)
printf("\nNu se poate deschide fisierul %s", numef);
for (i = 0; i < 20; i++)
x.note[i] = 0;
printf("Nume si prenume: "); gets(x.nume);
while (!feof(stdin))
printf("CNP: "); fflush(stdin); gets(x.cnp);
printf("Data nasterii: \n");
printf("An: "); scanf("%d", &;
printf("Luna:"); scanf("%d", &x.d.luna);
printf("Zi: "); scanf("%d", &x.d.zi);
printf("Nr. matricol:"); scanf("%d", &x.nrm);
printf("Facutate: "); fflush(stdin); gets(x.fac);
printf("An de studiu: "); scanf("%d", &;
printf("Grupa: "); scanf("%d", &x.grupa);
printf("Serie: "); fflush(stdin); scanf("%c", &x.s);
printf("Specializare: "); fflush(stdin); gets(x.spec);
fwrite(&x, sizeof(STUDENT), 1, f);
printf("Nume si prenume (sau CTRL+Z): "); fflush(stdin); gets(x.nume);
printf("Gata, apasa o tasta...");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.