最近アルゴリズムを勉強し始めた者ですが、連結リストについて質問があります。
以下のコードなのですが、
typedef struct _list{
int value;
struct _list* next;
} list;
// node の直後に value を追加する
void list_new(list* node, int value) {
list* n = (list*)malloc(sizeof(list));
n->value = value;
n->next = node->next;
node->next = n;
}
// node の直後の要素を削除する
void list_delete(list* node) {
if(node->next == NULL) return;
list* next = node->next;
node->next = next->next;
free(next);
}
int main(void) {
int i;
list a = {-1, NULL};
list *last = &a, *p;
for(i=0; i<10; ++i){
// 値の追加
if(a.value == -1){
a.value = i*i;
}else{
list_new(last, i*i);
last = last->next;
}
}
for(p = &a; p != NULL; p = p->next){
// 値の表示
printf(“%d\n”, p->value);
}
while(a.next != NULL){
// 後処理(値の削除)
list_delete(&a);
return 0;
}
*lastは構造体のポインタで、aは24行目で作った構造体、*pも新しく作った構造体のポインタですよね?
これが*lastとイコールとはどういうことですか?