작성
·
583
0
struct person
{
int id;
struct { char first[20]; char last[20]; };
};
struct person2
{
int id;
char first[20];
char last[20];
};
위의 코드와 아래의 코드는 접근방식이 완전히 똑같다고 볼수있는데 굳이 익명구조체를 쓸 필요가 있나요?
익명구조체만이 가지는 어떤 장점같은게 있는걸까요
답변 1
1
union 이랑 같이 쓸 때 좋은 것 같네요! 자세한건 링크 참고해주세요 :) 이유가 많네요..!
https://stackoverflow.com/questions/13376494/what-are-the-benefits-of-unnamed-structs-unions-in-c