프로그래밍 언어 활용난도 중상
18번 · 주관식 · 5점
다음 C 프로그램의 실행 결과를 쓰시오.
#include <stdio.h>
#include <stdlib.h>
struct Node {
char value;
struct Node *next;
};
struct Node *make_list(const char *text) {
struct Node *head = NULL;
while (*text) {
struct Node *node = malloc(sizeof(struct Node));
node->value = *text++;
node->next = head;
head = node;
}
return head;
}
int main(void) {
struct Node *current = make_list("BEST");
while (current) {
putchar(current->value);
struct Node *old = current;
current = current->next;
free(old);
}
return 0;
}