Unit 2 · Lesson 625 minAcademic review pending

Follow records through pointers

Use pointers to structures and understand how a self-referential structure describes a linked chain.

Choose explanation

After this lesson

You should be able to

  • Access structure fields through a pointer with the arrow operator.
  • Describe nodes and links without implementing a complete linked list.
01

Dot for an object, arrow for a pointer

If student is a structure object, use student.score. If p points to that structure, use p->score, which means (*p).score. Parentheses matter because the dot operator binds before unary dereference.

Passing a structure pointer lets a function update the original record and avoids copying a large structure. Use a pointer to const when the function should inspect but not modify the record.

Update one field
void addBonus(struct Student *student, double bonus) {
    if (student != NULL) {
        student->score += bonus;
    }
}
02

A node that knows the next node

A self-referential structure contains a pointer to another object of the same structure type. A Node can hold data and a next pointer. A linked list is then a chain reached from a head pointer; the final next pointer is null.

The structure contains a pointer, not another full Node directly. Embedding a full Node inside itself would require infinite size. This lesson stops at the concept, matching the syllabus boundary.

Self-referential shape
struct Node {
    int value;
    struct Node *next;
};

Try it yourself

Write an expression that reads the value field of the node after current, assuming both pointers are valid.

Need a hint?

Follow next once, then select value.

Check the worked solution

Use current->next->value. In real code, check current and current->next before reading.

Quick check

Why does a self-referential structure contain a pointer to its own type?

Select an answer to check your thinking.

Why this lesson exists

Syllabus mapping

Pointers to structures · Self-referential structures · Linked-list concept without implementation

Maps to course outcomes CO3, CO5.