課題7-2（下記に記載）で作成したリストで表現されたスタックに対して、pushを行う関数
を作成せよ。push関数を呼び出す前と後でprint_stack_listを呼びだし、push関数が正常に動いている
ことを確認せよ。
（ヒント）push関数のプロトタイプ宣言はvoid push(struct data **top, char key);のようにする。
（課題7ー2）

#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;
        }
}
