Null terminated string

I have acquired a String, and I do not know if it is null terminated or not. I need to pass it to a win32 function, which needs the string to be null terminated.

Do I just push a 0 to the end of the string, or is there a different string type I should be using which is specifically designed for C ffi?

Update: Ah, CString. :slight_smile:

1 Like

Right -- in addition to adding a trailing '\0', CString ensures that there are no '\0's within the string data, which is normally fine (if weird) for a Rust String.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.