rust - How do I get a *mut c_char from a Str? -
To use the C library, I will assign a * mut c_char parameter to the function. But I can not find any way to get it from str .
I changed my str to one, it's okay, but there is no other way than CString * mut c_char In the construction of the night I found that 0.12.0 in one Was, but now, that * mut c_char ?
two bytes = string: from_str ("test"). In_bytes () + b "\ 0"; Let's cchars = bytes. Map_in_place (| b | b as c_char); Name: * mut c_char = cchars.as_mut_ptr (); The basic idea is the same as yours, but Vec is no need to split clearly; A zero byte is also added to the buffer. See also my comment on the question.
Comments
Post a Comment