yeolyi.comSeongyeol's CS

Lab

C

Run C code one line at a time and see each function's variables and the memory you malloc'd. Edit the code and it runs and records again.

1#include <stdio.h>
2#include <stdlib.h>
3
4struct Node {
5 int value;
6 struct Node *next;
7};
8
9// 맨 앞에 새 노드 넣기
10struct Node *push(struct Node *head,
11 int value) {
12 struct Node *node =
13 malloc(sizeof(struct Node));
14 node->value = value;
15 node->next = head;
16 return node;
17}
18
19int main(void) {
20 struct Node *head = NULL;
21 head = push(head, 30);
22 head = push(head, 20);
23 head = push(head, 10);
24
25 // 처음부터 따라가며 읽기
26 struct Node *p = head;
27 while (p != NULL) {
28 printf("%d\n", p->value);
29 p = p->next;
30 }
31 return 0;
32}
33

No variables
No output