mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 07:33:57 +00:00
Addressing wrong type for the pointer example
The other option would be to change x from const to var: ``` var x: i32 =1; const pointer: *i32 = &x ```
This commit is contained in:
parent
c3c2f20a80
commit
31edc043d2
2
zig.md
2
zig.md
@ -204,7 +204,7 @@ const slice = array[0..array.len]; // "slice" represents the whole array.
|
|||||||
```zig
|
```zig
|
||||||
// Pointer on a value can be created with "&".
|
// Pointer on a value can be created with "&".
|
||||||
const x: i32 = 1;
|
const x: i32 = 1;
|
||||||
const pointer: *i32 = &x; // "pointer" is a pointer on the i32 var "x".
|
const pointer: *const i32 = &x; // "pointer" is a pointer on the const i32 var "x".
|
||||||
print("1 = {}, {}\n", .{x, pointer});
|
print("1 = {}, {}\n", .{x, pointer});
|
||||||
|
|
||||||
// Pointer values are accessed and modified with ".*".
|
// Pointer values are accessed and modified with ".*".
|
||||||
|
Loading…
Reference in New Issue
Block a user