#include #include #include #define N 5 struct Foititis{ char am[10]; char epi[20]; char ono[20]; float mo; }; struct IFoititis{ char am[10]; int dief; }; void selection_sort(struct IFoititis * , int); main() { struct Foititis f; struct IFoititis *foi , temp; FILE *dataf; FILE *indexf; int pl , m=0 , i , j , tm; int syn; dataf = fopen("Foititis.dat" , "rb+"); if (!dataf) { dataf = fopen("Foititis.dat" , "wb"); indexf = fopen("Foititis.ndx" , "wb"); fclose(indexf); pl = 0; } else { indexf = fopen("Foititis.ndx" , "rb"); fseek(indexf , 0 , SEEK_END); pl = ftell(indexf) / sizeof(struct IFoititis); fclose(indexf); fseek(dataf , 0 , SEEK_END); } m = pl; foi = malloc((pl+N) * sizeof(struct IFoititis)); printf("\n\nEISAGOGI EGGRAFON\n\n"); do{ printf("\nEisagogi Aritmou Mitroou :"); scanf("%s", &f.am); printf("\nEisagogi Epithetou :"); scanf("%s", &f.epi); printf("\nEisagogi Onomatos :"); scanf("%s", &f.ono); printf("\nEisagogi Mesou Orou :"); scanf("%f", &f.mo); fwrite(&f , sizeof(struct Foititis) , 1 , dataf); strcpy(foi[m].am , f.am); foi[m].dief = m; m++; printf("\n\n Thelete nea eisagogi (1=NAI , 0=OXI) : "); scanf("%d" , &syn); } while ((syn == 1) && (m < pl+N)); fclose(dataf); indexf = fopen("Foititis.ndx" , "rb+"); fseek(indexf , 0 , SEEK_END); for (i=pl; i0) t = j; temp = x[i]; x[i] = x[t]; x[t] = temp; } }