#include <stdio.h>
struct ps {
char name[100];
int year;
double ht;
double wt;
};
int main(void)
{
FILE *in;
FILE *out;
struct ps inv[3];
int i = 0;
char buf[100];
in
= fopen("data.txt", "r"); /* fread(inv, sizeof(struct ps), 3, in); */
for(i=0; i<3; i++) {
fgets(buf
,sizeof(buf
),in
); inv[i].name, &inv[i].year, &inv[i].ht, &inv[i].wt);
inv[i].name, inv[i].year, inv[i].ht, inv[i].wt);
}
out
= fopen("new.txt", "w"); for(i=0; i<3; i++) {
inv[i].name, inv[i].year, inv[i].ht, inv[i].wt);
}
/* fwrite(inv, sizeof(struct ps), 3, out); */
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CnN0cnVjdCBwcyB7CiAgY2hhciBuYW1lWzEwMF07CiAgaW50ICB5ZWFyOwogIGRvdWJsZSBodDsKICBkb3VibGUgd3Q7Cn07CmludCBtYWluKHZvaWQpCnsKICBGSUxFICppbjsKICBGSUxFICpvdXQ7CiAgc3RydWN0IHBzIGludlszXTsKICBpbnQgIGkgPSAwOwogIGNoYXIgYnVmWzEwMF07CgogIGluID0gZm9wZW4oImRhdGEudHh0IiwgInIiKTsKICAvKiAgIGZyZWFkKGludiwgc2l6ZW9mKHN0cnVjdCBwcyksIDMsIGluKTsgKi8KICBmb3IoaT0wOyBpPDM7IGkrKykgewogICAgZmdldHMoYnVmLHNpemVvZihidWYpLGluKTsKICAgIHNzY2FuZihidWYsIiVzICVkICVsZiAlbGYiLAogICAgICAgICAgIGludltpXS5uYW1lLCAmaW52W2ldLnllYXIsICZpbnZbaV0uaHQsICZpbnZbaV0ud3QpOwogICAgcHJpbnRmKCIlc1x0JTVkJTcuMWYlNy4xZlxuIiwKICAgICAgICAgICBpbnZbaV0ubmFtZSwgaW52W2ldLnllYXIsIGludltpXS5odCwgaW52W2ldLnd0KTsKICB9CiAgZmNsb3NlKGluKTsKCiAgb3V0ID0gZm9wZW4oIm5ldy50eHQiLCAidyIpOwogIGZvcihpPTA7IGk8MzsgaSsrKSB7CiAgICBmcHJpbnRmKG91dCwiJXNcdCU1ZCU3LjFmJTcuMWZcbiIsCiAgICAgICAgICAgIGludltpXS5uYW1lLCBpbnZbaV0ueWVhciwgaW52W2ldLmh0LCBpbnZbaV0ud3QpOwogIH0KICAvKiAgZndyaXRlKGludiwgc2l6ZW9mKHN0cnVjdCBwcyksIDMsIG91dCk7ICovCiAgZmNsb3NlKG91dCk7CiAgcmV0dXJuIDA7Cn0=