#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;
char values[4] = {'a', 'b', 'c', 'd'};
int i;
top = NULL;
for (i = 0; i < 4; i++) {
cur
= (struct data
*)malloc(sizeof(struct data
)); if (cur == NULL) {
return 1;
}
cur->key = values[i];
cur->next = top;
top = cur;
}
print_stack_list(top);
return 0;
}
void print_stack_list(struct data *top) {
while (top != NULL) {
top = top->next;
}
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RyaW5nLmg+CiNpbmNsdWRlPHN0ZGxpYi5oPgoKc3RydWN0IGRhdGF7CgljaGFyIGtleTsKCXN0cnVjdCBkYXRhICpuZXh0Owp9OwoKdm9pZCBwcmludF9zdGFja19saXN0KHN0cnVjdCBkYXRhICp0b3ApOwoKaW50IG1haW4oKSB7CglzdHJ1Y3QgZGF0YSAqdG9wLCAqY3VyOwoJY2hhciB2YWx1ZXNbNF0gPSB7J2EnLCAnYicsICdjJywgJ2QnfTsKCWludCBpOwoJdG9wID0gTlVMTDsKCWZvciAoaSA9IDA7IGkgPCA0OyBpKyspIHsKCQljdXIgPSAoc3RydWN0IGRhdGEqKW1hbGxvYyhzaXplb2Yoc3RydWN0IGRhdGEpKTsKCQlpZiAoY3VyID09IE5VTEwpIHsKCQkJcHJpbnRmKCLjg6Hjg6LjgorjgYznorrkv53jgafjgY3jgb7jgZvjgpPjgafjgZfjgZ/jgIJcbiIpOwoJCQlyZXR1cm4gMTsKCQl9CgkJY3VyLT5rZXkgPSB2YWx1ZXNbaV07CgkJY3VyLT5uZXh0ID0gdG9wOwoJCXRvcCA9IGN1cjsKCX0KCXByaW50X3N0YWNrX2xpc3QodG9wKTsKCXJldHVybiAwOwp9Cgp2b2lkIHByaW50X3N0YWNrX2xpc3Qoc3RydWN0IGRhdGEgKnRvcCkgewoJd2hpbGUgKHRvcCAhPSBOVUxMKSB7CgkJcHJpbnRmKCIlY1xuIix0b3AtPmtleSk7CgkJdG9wID0gdG9wLT5uZXh0OwoJfQp9