'Zig error: Array access of non-array type
I need some help on creating an array as a struct field in Zig.
const VarStr = struct {
buffer: [1000]u8,
len: u8,
pub fn init(str: []const u8) VarStr {
var filled: u8 = 0;
for (str) |char, ind| {
.buffer[ind] = char;
filled = ind + 1;
}
while (filled < 999) {
.buffer[filled] = null;
}
}
};
When i compile, it gives me the following error
error: array access of non-array type '@Type(.EnumLiteral)'
.buffer[ind] = char;
^
Where did I go wrong? please help, thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
