How to create string array in Rust

1 Answer

0 votes
fn main() {
    let arr: [&str; 4] = ["rust", "c", "c++", "java"];
    
    for s in &arr {
        println!("{}", s);
    }
}




/*
run:

rust
c
c++
java

*/

 



answered Mar 5, 2023 by avibootz

Related questions

...