/** * leo.c * * @descripcion lee un fichero y vuelca los datos estructuras del tipo registro */ #include /* registro */ struct registro { int edad; char nombre[60]; }; int main() { int i; FILE *f; struct registro r; /* leemos 3 registros */ f=fopen("registros.dat","r"); if (!f) return 1; for (i=1;i<=3; i++) { fread(&r,sizeof(struct registro),1,f); printf("edad: %d\n",r.edad); printf("nombre: %s\n",r.nombre); } fclose(f); printf("\n"); return 0; }