#Getting a u8 slice (`[]u8`) from a string?
1 messages · Page 1 of 1 (latest)
if you need to mutate the string afterwards you need a place for it to live, since slices are pointers and dont hold data. easiest way is just doing this:
var name_arr = “lda (71),Y”.*;
const name: []u8 = &name_arr;
if you dont need it to be mutable, then you can just make this change name: []u8 => name: []const u8
the error is about trying to get a mutable pointer from a const pointer
const name: [] const u8 is this valid zig tho?
Yeah doesn't seem to be
src/cpu.zig:436:17: error: expected type expression, found 'const'
const name: const []u8 = "lda (71),Y";
^~~~~
yes, const before the variable name means it cant be reassigned and the const after the [] means the contents cant be changed
np, its the same as *const T