#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct data_list {
struct data_list *next;
char data[];
};
int main(int argc, char **argv)
{
int res;
char buf[1024];
struct data_list data_list = { 0 }, *p;
int l;
fputs("文字列を入力してください。ctrl-dで終了:\n", stderr
); for (;;) {
if (fgets(buf
, sizeof(buf
) - 1, stdin
) == NULL
) break;
for (p = &data_list; p->next != NULL; p = p->next);
p
->next
= malloc(sizeof(data_list
) + l
+ 1); if (p->next == NULL) {
res = 1;
goto PG_END;
}
p->next->next = NULL;
}
for (p = data_list.next; p != NULL; p = p->next)
res = 0;
PG_END:;
// free
for (p = data_list.next; p; p = p->next)
return res;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKc3RydWN0IGRhdGFfbGlzdCB7CiAgICBzdHJ1Y3QgZGF0YV9saXN0ICpuZXh0OwogICAgY2hhciBkYXRhW107Cn07CgppbnQgbWFpbihpbnQgYXJnYywgY2hhciAqKmFyZ3YpCnsKICAgIGludCByZXM7CiAgICBjaGFyIGJ1ZlsxMDI0XTsKICAgIHN0cnVjdCBkYXRhX2xpc3QgZGF0YV9saXN0ID0geyAwIH0sICpwOwogICAgaW50IGw7CgogICAgZnB1dHMoIuaWh+Wtl+WIl+OCkuWFpeWKm+OBl+OBpuOBj+OBoOOBleOBhOOAgmN0cmwtZOOBp+e1guS6hjpcbiIsIHN0ZGVycik7CiAgICBmb3IgKDs7KSB7CiAgICAgICAgZnB1dHMoIj8gIiwgc3RkZXJyKTsKICAgICAgICBpZiAoZmdldHMoYnVmLCBzaXplb2YoYnVmKSAtIDEsIHN0ZGluKSA9PSBOVUxMKQogICAgICAgICAgICBicmVhazsKICAgICAgICBsID0gc3RybGVuKGJ1Zik7CiAgICAgICAgZm9yIChwID0gJmRhdGFfbGlzdDsgcC0+bmV4dCAhPSBOVUxMOyBwID0gcC0+bmV4dCk7CiAgICAgICAgcC0+bmV4dCA9IG1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