I'm just getting started with Zig and come from C++ and Rust;
I've been struck early with a difficult issue that I cannot seem to solve. Or find anywhere on the internet.
This is what I have:
// this doesn't work
pub const User = struct {
bot: bool,
id: *const [*:0]u8,
username: *const [*:0]u8,
pub fn init() User {
return User {
.bot = false,
.id = "THIS_IS_ID",
.username = "THIS_IS_USERNAME"
};
}
...
}
const user = User.init();
// this works vvv
id: *const [10:0]u8,
.id = "THIS_IS_ID",
This is the error I get:
error: expected type '*const [*:0]u8', found '*const [10:0]u8'
.id = "THIS_IS_ID",
My objective that I'm trying to get out of asking this question is to know if it's possible to have dynamic strings in zig; and if so, how so? I've seen some custom String structs online but was wondering if there is a way to achieve this without creating a separate type / struct for it..?
Thanks for the help!