이제야 알게됨
C언어에서 화살표연산자는 구조체에서만 사용된다...
그러므로 이제는 연결리스트를 할 수 있게됨 ㅋㅋ
#include <stdio.h>
#include <stdlib.h>
struct NODE {
char* data;
struct NODE* link;
};
int main() {
struct NODE* week = (struct NODE*)calloc(1, sizeof(struct NODE));
struct NODE* node1 = (struct NODE*)calloc(1, sizeof(struct NODE));
struct NODE* node2 = (struct NODE*)calloc(1, sizeof(struct NODE));
struct NODE* node3 = (struct NODE*)calloc(1, sizeof(struct NODE));
week->link = node1;
node1->data = "MON";
node1->link = node2;
node2->data = "TUE";
node2->link = node3;
node3->data = "WED";
node3->link = NULL;
struct NODE *curr = week->link;
while (curr != NULL) {
printf("Today is %s\n", curr->data);
curr = curr->link;
}
free(week);
free(node1);
free(node2);
free(node3);
return 0;
}
이거 이해한건 아님.
node2->data = 6;
node2->link= node1->link;
node1->link = node2;