#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct data{
char key;
struct data *next;
};
void print_stack_list(struct data *top);
int main()
{
struct data *top, *cur;
top
= (struct data
*)malloc(sizeof(struct data
)); if(top
== NULL
){printf("メモりが確保できませんでした。\n"); return 1; } cur = top;
top->key = 'a';
top
->next
= (struct data
*)malloc(sizeof(struct data
)); if(top
->next
== NULL
){printf("メモりが確保できませんでした。\n"); return 1; } top = top->next;
top->key = 'b';
top
->next
= (struct data
*)malloc(sizeof(struct data
)); if(top
->next
== NULL
){printf("メモりが確保できませんでした。\n"); return 1; }
top = top->next;
top->key = 'c';
top->next = NULL;
top = cur;
print_stack_list(top);
return 0;
}
void print_stack_list(struct data *top)
{
while(top !=NULL)
{
top = top->next;
}
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RyaW5nLmg+CiNpbmNsdWRlPHN0ZGxpYi5oPgoKc3RydWN0IGRhdGF7CiAgY2hhciBrZXk7CiAgc3RydWN0IGRhdGEgKm5leHQ7Cn07Cgp2b2lkIHByaW50X3N0YWNrX2xpc3Qoc3RydWN0IGRhdGEgKnRvcCk7CgppbnQgbWFpbigpCnsKICBzdHJ1Y3QgZGF0YSAqdG9wLCAqY3VyOwogCiAgdG9wID0gKHN0cnVjdCBkYXRhKiltYWxsb2Moc2l6ZW9mKHN0cnVjdCBkYXRhKSk7CiAgaWYodG9wID09IE5VTEwpe3ByaW50Zigi44Oh44Oi44KK44GM56K65L+d44Gn44GN44G+44Gb44KT44Gn44GX44Gf44CCXG4iKTsgcmV0dXJuIDE7ICAgICB9CiAgY3VyID0gdG9wOwogIHRvcC0+a2V5ID0gJ2EnOwogIHRvcC0+bmV4dCA9IChzdHJ1Y3QgZGF0YSopbWFsbG9jKHNpemVvZihzdHJ1Y3QgZGF0YSkpOwogIGlmKHRvcC0+bmV4dCA9PSBOVUxMKXtwcmludGYoIuODoeODouOCiuOBjOeiuuS/neOBp+OBjeOBvuOBm+OCk+OBp+OBl+OBn+OAgl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