코딩Coding/Rust연습

Rust연습❤️] Displaying raw pointers

내인생PLUS 2022. 7. 3. 00:38
728x90

 

 

 

결과

// https://riptutorial.com/rust/example/24222/displaying-raw-pointers
use std::ptr;

// Create some data, a raw pointer pointing to it and a null pointer
fn main() {
    let data: u32 = 42;
    let raw_ptr = &data as *const u32;
    let null_ptr = ptr::null() as *const u32;

    // the {:p} mapping shows pointer values as hexadecimal memory addresses
    println!("Data address: {:p}", &data);
    println!("Raw pointer address: {:p}", raw_ptr);
    println!("Null pointer address: {:p}", null_ptr);
}

 

Displaying raw pointers

cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/rust_polyglot`


Data address: 0x16d7dea6c
Raw pointer address: 0x16d7dea6c
Null pointer address: 0x0

 

출처 :

https://riptutorial.com/rust/example/24222/displaying-raw-pointers

 

Rust Tutorial => Displaying raw pointers

Learn Rust - Displaying raw pointers

riptutorial.com

 

 

 

 

 

 

 

 


 

반응형