Call a foreign-language function: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: added syntax colouring, marked p2js incompatible)
(Added Zig)
Line 3,262: Line 3,262:
Goodbye, World!
Goodbye, World!
</pre>
</pre>

=={{header|Zig}}==
<lang zig>const std = @import("std");
const c = @cImport({
@cInclude("stdlib.h"); // `free`
@cInclude("string.h"); // `strdup`
});

pub fn main() !void {
const string = "Hello World!";
var copy = c.strdup(string);

try std.io.getStdOut().writer().print("{s}\n", .{copy});
c.free(copy);
}</lang>


=={{header|zkl}}==
=={{header|zkl}}==