Skip to content

Commit

Permalink
Merge pull request #124 from pedropark99/fix-110
Browse files Browse the repository at this point in the history
Fix a code example in the Pointers chapter
  • Loading branch information
pedropark99 authored Feb 9, 2025
2 parents f0078b9 + 9ea48cd commit e907399
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
15 changes: 9 additions & 6 deletions Chapters/05-pointers.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,17 @@ to the first element in the array `ar`. But then, I started to walk through the
the pointer with simple pointer arithmetic.

```{zig}
#| eval: false
const ar = [_]i32{1,2,3,4};
var ptr = &ar;
try stdout.print("{d}\n", .{ptr.*});
#| eval: true
#| auto_main: true
#| build_type: "run"
#| results: "hide"
const ar = [_]i32{ 1, 2, 3, 4 };
var ptr: [*]const i32 = &ar;
try stdout.print("{d}\n", .{ptr[0]});
ptr += 1;
try stdout.print("{d}\n", .{ptr.*});
try stdout.print("{d}\n", .{ptr[0]});
ptr += 1;
try stdout.print("{d}\n", .{ptr.*});
try stdout.print("{d}\n", .{ptr[0]});
```

```
Expand Down
Loading

0 comments on commit e907399

Please # to comment.