-는 뭐할때쓰는건가요?
상처입은마음
2023.04.01
-
아잉누님
위에 보면 a,b가 구조체 포인터로 선언한후 구조체를 메모리 heap영역에 할당해 줬잖아요^^ 즉 a란구조체포인터가 구조체 변수를 그리키는 뜻입니다,a가 가르키고 있는 구조체 안에 있는 data에 123을 넣겠다는 말이죠^^
-
무리한
구조체변수이름.구조체멤버변수
구조체포인터변수이름-구조체멤버변수 -
조으다
ex]
#include stdio.h
#include stdlib.h
struct listnode
{
int data;
struct listnode *link;
};
void main(void)
{
struct listnode *a, *b;
a = (struct listnode *)malloc(sizeof(struct listnode));
b = (struct listnode *)malloc(sizeof(struct listnod