Initializing a Vector{Cuchar} (string) prior to calling a C function

datetime = zeros(Cuchar, 28)

If the string is NUL-terminated and you want to convert it to a corresponding String, but not including the NUL character(s) (i.e. if you want "2002-05-02T02" in your case), you can do e.g.

dt = String(datetime[1:findfirst(iszero, datetime)-1])

or alternatively (using lower-level operations to avoid copying data unnecessarily).

dt = GC.@preserve datetime unsafe_string(pointer(datetime))
2 Likes