#include "stdafx.h" typedef struct ficha { int edad; float peso; char nombre[40]; } tficha; char genletra2() { return 'a' + rand() % 26; } void gencad(char C[], int dimc) { int lon = rand() % (dimc - 1), i; for (i = 0; i < lon; i++) C[i] = genletra2(); C[i] = '\0'; } void gen_tficha(tficha * ptficha) { ptficha->edad = rand() % 120; ptficha->peso = 1 + rand() % 300; gencad(ptficha->nombre, 39); } void impr_tficha(tficha * ptficha) { printf("\n edad %d \n", ptficha->edad); printf("peso %g \n", ptficha->peso); puts(ptficha->nombre); } void fimpr_tficha(FILE * pf, tficha * ptficha) { fprintf(pf, "\n edad %d \n", ptficha->edad); fprintf(pf, "peso %g \n", ptficha->peso); fputs(ptficha->nombre, pf); } void fleer_tficha(FILE * pf, tficha * ptficha) { fscanf(pf, "\n edad %d \n", &(ptficha->edad)); fscanf(pf, "peso %g \n", &(ptficha->peso)); fgets(ptficha->nombre, 40, pf); } void copy_tficha(tficha *origen, tficha *destino) { int sz = sizeof(tficha), i; char *f = (char*)origen, *f1 = (char*)destino; for (i = 0; i