#Printing memory content

1 messages · Page 1 of 1 (latest)

wanton remnant
#

Assuming a sentinel-terminated pointer, how can one print individual bytes of the region that it's pointing to?
Iteration seems not possible due to error: type '[*:0]const u8' does not support field access for (foobar) |character, i| {
i guess std.fmt.fmtSliceHexLower can help but results in expected type '[]const u8', found '[*:0]const u8' also you can't format individual bytes with that.

round bison
#

there might be something in std, but iteration is totally possible

#

you just need to use a while loop

#

or you can just create a slice (which is what for and most std functions are expecting) if you know the size

#

which you can find with std.mem.len

wanton remnant
#

using a slice works thx 🙂

round bison
#

and a slice can also be printed with normal formatting functions

#

with {x} I think, if you want hex