2017-06-09 21 views
-1

私はこの構造に出くわしました。私はそれらを別々に書いているので、私は愚かなので、両方を "解剖"するのに苦労しています。ここで構造/リンクされたリストを理解する

は、構造体です:

typedef struct no_disciplina * ListDisciplinas; 

typedef struct no_disciplina 
{  
    char * nome;  
    struct no_apont_aluno * alunos;  
    ListDisciplinas next; 
} NoDisciplina; 

typedef struct no_aluno * ListAlunos; 

typedef struct no_aluno 
{  
    char * nome; 
    int numero; 
    struct no_apont_disciplina * disciplinas; 
    ListAlunos next; 
} NoAluno; 

typedef struct no_apont_disciplina * ListApontDisciplinas; 

typedef struct no_apont_disciplina 
{ ListDisciplinas disciplina; 
     ListApontDisciplinas next; 
} NoApontDisciplina; 

typedef struct no_apont_aluno * ListApontAlunos; 

typedef struct no_apont_aluno 
{  
    ListAlunos aluno; 
    ListApontAlunos next; 
} NoApontAluno; 

また、これらのリンクリストは、ヘッダ(単にリストの最初の「本当の」ノードへのポインタで構成されるノード)を持っていないと言われてそうか私はそれを定義するのですか?

ありがとうございます:D!

答えて

0

ですから、今の頭 "だから、

node_t * head = NULL; 
head = malloc(sizeof(node_t)); 
if (head == NULL) { 
    return 1; 
} 

head->val = 'a'; 
head->next = NULL; 

、あなたはこのような何かをするだろう頭とリンクリストを使用してそのように、

typedef struct node { 
    char val; 
    struct node * next; 
} node_t; 

ようなあなたのリンクリストを定義しますあなたのヘッダーであり、あなたが定義する後続のノードは最後の要素が末尾である '頭'に付けられます。

+0

私はラインtypedef struct no_disciplina * ListDisciplinasを推測しています。リストのヘッダを作る? –

関連する問題