about summary refs log tree commit diff
path: root/lang/zig/c-string.zig
blob: 537fa3bc76994fb7e680f6db3dc53e8d3e922367 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
const std = @import("std");

// This is also available as `std.c.printf`.
pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;

pub fn main() anyerror!void {
    _ = printf("Hello, world!\n"); // OK

    const msg = "Hello, world!\n";
    const non_null_terminated_msg: [msg.len]u8 = msg.*;
    _ = printf(&non_null_terminated_msg);
}