#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) {
			printf("メモりが確保できませんでした。\n");
			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) {
		printf("%c\n",top->key);
		top = top->next;
	}
}