I am stuck why the println on is *p1.offset(0)
is giving me 0. Any ideas?
fn main() {
let p1 : *const u8 = vec![17u8,2u8].as_ptr();
let p2 : *const u8 = "123".as_ptr();
unsafe{
println!("{}", *p1.offset(0) as u8);//should get 17, but I get 0
println!("{}", *p2.offset(0) as char);
}
}
Here is the link to playground. https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=18222645e5fa43cde787659402962be3