Learning Zig from the official language reference.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
zig-langref/sentinel_terminated_pointer...

13 lines
367 B

const std = @import("std");
const debug = std.debug;
const testing = std.testing;
pub extern "c" fn printf(fmt: [*:0]const u8, ...) c_int;
test "sentinel-terminated pointers" {
_ = printf("%s\n", "Hello, world");
const msg = "Hello again, world!";
const non_null_terminated_string: [msg.len]u8 = msg.*;
//_ = printf(&non_null_terminated_string);
}