Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use libc::c_char;
- use std::ffi::CStr;
- type GiveCChar = extern "C" fn(*const c_char);
- extern "C" {
- fn hello(give_c_char: GiveCChar);
- }
- fn main() {
- unsafe { hello(print_cstr); }
- }
- extern "C" fn print_cstr(c: *const c_char) {
- let x = unsafe { CStr::from_ptr(c) };
- println!("{:?}", x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement