ethos/tests/pointer.ethlang
sfja a42917b485
All checks were successful
Check / Explore-Gitea-Actions (push) Successful in 8s
add debug_print
2026-03-17 18:55:54 +01:00

30 lines
390 B
Plaintext

fn change_to(place: *mut int, value: int)
{
*place = value;
}
fn main()
{
let a = 1;
let b: *int = &a;
// expect: 1
debug_print(*b);
a = 2;
// expect: 2
debug_print(*b);
let c: *mut int = &mut a;
*c = 3;
// expect: 3
debug_print(a);
// expect: 3
debug_print(*c);
change_to(&mut a, 4);
// expect: 4
debug_print(a);
}