Address of a variable: Difference between revisions

Content added Content deleted
imported>Acediast
(→‎{{header|COBOL}}: syntax highlighting doesn't support freeform 🗿)
m (→‎{{header|Zig}}: update @ptrToInt() to @intFromPtr() for Zig 0.11.0)
Line 2,421: Line 2,421:


=={{header|Zig}}==
=={{header|Zig}}==
{{works with|Zig|0.11.0}}
<syntaxhighlight lang="zig">const std = @import("std");
<syntaxhighlight lang="zig">const std = @import("std");

pub fn main() !void {
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
const stdout = std.io.getStdOut().writer();
Line 2,428: Line 2,429:
var address_of_i: *i32 = &i;
var address_of_i: *i32 = &i;


try stdout.print("{x}\n", .{@ptrToInt(address_of_i)});
try stdout.print("{x}\n", .{@intFromPtr(address_of_i)});
}</syntaxhighlight>
}</syntaxhighlight>