pointers exercises done

This commit is contained in:
2026-06-06 23:27:39 +02:00
parent a5bbd016eb
commit 28a82c5c08
4 changed files with 5 additions and 3 deletions
+2
View File
@@ -18,12 +18,14 @@ const Elephant = struct {
pub fn main() void {
var elephantA = Elephant{ .letter = 'A' };
var elephantB = Elephant{ .letter = 'B' };
// (Please add Elephant B here!)
var elephantC = Elephant{ .letter = 'C' };
// Link the elephants so that each tail "points" to the next elephant.
// They make a circle: A->B->C->A...
elephantA.tail = &elephantB;
elephantB.tail = &elephantC;
// (Please link Elephant B's tail to Elephant C here!)
elephantC.tail = &elephantA;