Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Creeaza fisierul text cu informatiile din fisierul binar de la 'creare_fisier.c'
#include<stdio.h>
#include<conio.h>
typedef struct{
unsigned int an;
unsigned char luna;
unsigned char zi;
}DATA;
typedef struct{
char nume[20];
char cnp[14];
DATA d;
unsigned int nrm;
char fac[6];
unsigned char an;
unsigned int grupa;
char s;
char spec[11];
char note[20];
}STUDENT;
void main()
{
FILE* f;
FILE* g;
STUDENT x;
char numef[20];
int i, nr;
printf("Nume fisier: "); gets(numef);
f = fopen(numef, "rb");
if (!f)
printf("\nNu se poate deschide fisierul cu numele %s", numef);
else
{
g = fopen("Lista.txt", "wt");
fprintf(g, "\t\tLista studentilor\n");
fprintf(g, "Nrcrt %-19s Nrmat Fac. Specializare A Grupa S Data nast. Note", "Nume si prenume");
nr = 0;
fread(&x, sizeof(STUDENT), 1, f);
while (!feof(f))
{
fprintf(g, "\n%5d %-19s %5d %-5s %-12s %d %5d %c %2d.%2d.%4d ",
++nr, x.nume, x.nrm, x.fac, x.spec, x.an, x.grupa, x.s,
x.d.zi, x.d.luna, x.d.an);
for (i = 0; i < 20; i++)
fprintf(g, "%2d ", x.note[i]);
fread(&x, sizeof(STUDENT), 1, f);
}
fclose(f);
fclose(g);
}
printf("gata, apasa o tasta...");
_getch();
}
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.