구조체 안의 구조체 처리방법...?

ch0nn0m의 이미지

channel구조체의 멤버 channel_name에 문자열을 저장을 하고
user의 멤버인 u_name에는 또다른 문자열을 저장하려고 합니다...

해당 channel_name을 출력했을때...
그 안에 들어가있는 user의 u_name을 출력해보고 싶은데요...

너무 헷갈리네요...ㅠ.ㅠ

typedef struct _user
{
        char u_name[20];
        struct _user *u_next;
}user;
user *u_head, *u_tail;
 
typedef struct _channel
{
        int user_count;
        char channel_name[20];
        struct _channel *c_next;
        struct _user *user;
}channel;
channel *c_head, *c_tail;
freestyle의 이미지

'특정 채널'과 '출력'이라는 명령을 받으면

그 채널의 user 포인터부터 user_count가 0이 될때까지 계속 user이름을 출력하는 것이지요.

물론 user 포인터로부터 linked list같은 형태로 물려 있을 것이구요.

채널 포인터 변수를 some_channel로 가정하면,

while(user_count--)
{
    printf("%s\n", some_channel->user->u_name);
}

---------------------------
Go to the U-City

----------------------------------------------------------------------------------------
Don't Feed the Trolls!
----------------------------------------------------------------------------------------