How to update libc::c_char array with String


I have write some FFI code to C/C++,

use libc::c_char;
use std::ffi::CString;

type arr_type = [c_char; 20]; // arr_type is the type in C
let mut arr : arr_type = [0; 20]; 

let s = "happy123";
let c_s = CString::new(s).unwrap();
let s_ptr = c_s.as_ptr();

how can I update the arr with the String s in Rust ? in C/C++ I can use memcpy, strcpy etc…


please don’t double post to stackoverflow and to here.



Why not? Is there a rule against it?