#include #include int main() { int sn; FILE *fp; struct stu { int sno; int age; int wgt; }; struct stu *s; s = (struct stu*)malloc(sizeof(struct stu)); fp = fopen("law.dat", "rb"); fread(s, sizeof(struct stu), 1, fp); printf("input student no: \n"); fflush(stdin); scanf("%d", &sn); while(!feof(fp)) { if(sn == s->sno) printf("%d, %d, %d\n", s->sno, s->age, s->wgt); fread(s, sizeof(struct stu), 1, fp); } fclose(fp); return 0; }