Skip to content
Snippets Groups Projects
Commit ba4e9199 authored by Ridge's avatar Ridge
Browse files

bare3_2

parent 4e47498a
No related branches found
No related tags found
No related merge requests found
Pipeline #136 canceled
...@@ -18,8 +18,11 @@ use cortex_m_semihosting::{hprint, hprintln}; ...@@ -18,8 +18,11 @@ use cortex_m_semihosting::{hprint, hprintln};
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
hprintln!("bare3").unwrap(); hprintln!("bare3").unwrap();
let s = "ABCD"; let s: &str = "ABCD";
let bs = s.as_bytes(); let bs: &[u8] = s.as_bytes();
let c: &u8;
let i: i32;
let a: [u8; 4];
hprintln!("s = {}", s).unwrap(); hprintln!("s = {}", s).unwrap();
hprintln!("bs = {:?}", bs).unwrap(); hprintln!("bs = {:?}", bs).unwrap();
...@@ -36,7 +39,7 @@ fn main() -> ! { ...@@ -36,7 +39,7 @@ fn main() -> ! {
hprintln!("").unwrap(); hprintln!("").unwrap();
let a = [65u8; 4]; a = [65u8; 4];
//let mut a = [0u8; 4]; //let mut a = [0u8; 4];
hprintln!("").unwrap(); hprintln!("").unwrap();
...@@ -52,27 +55,38 @@ fn main() -> ! { ...@@ -52,27 +55,38 @@ fn main() -> ! {
// //
// 1. What is the output in the `openocd` (Adapter Output) console? // 1. What is the output in the `openocd` (Adapter Output) console?
// //
// ** your answer here ** // bare3
// s = ABCD
// bs = [65, 66, 67, 68]
// iterate over slice
// 65,66,67,68,iterate iterate using (raw) indexing
// 65,
// 66,
// 67,
// 68,
//
//
// a = AAAA
// //
// What is the type of `s`? // What is the type of `s`?
// //
// ** your answer here ** // type string
// //
// What is the type of `bs`? // What is the type of `bs`?
// //
// ** your answer here ** // u8 byte array
// //
// What is the type of `c`? // What is the type of `c`?
// //
// ** your answer here ** // Pointer for an u8 element in the bs array.
// //
// What is the type of `a`? // What is the type of `a`?
// //
// ** your answer here ** // it's an array of u8
// //
// What is the type of `i`? // What is the type of `i`?
// //
// ** your answer here ** // a int variable, i32
// //
// Commit your answers (bare3_1) // Commit your answers (bare3_1)
// //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment