Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::boxed::Box;
- use libc::c_void;
- fn main() {
- show_ptr(get_ptr());
- }
- fn get_ptr() -> *mut c_void {
- let x = vec!["Hello".to_string(), "World".to_string()].into_boxed_slice();
- Box::into_raw(x) as *mut c_void
- }
- fn show_ptr(ptr: *mut c_void) {
- let x = unsafe { Box::from_raw(ptr as *mut Box<[String]>) };
- println!("{:?}", x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement