How to split a string by whitespaces in Rust

1 Answer

0 votes
fn main() {        
    let s = "rust c c++ java python";
  
    for word in s.split_whitespace() {
        println!("{}", word);
    }
}




/*
run:

rust
c
c++
java
python

*/

 



answered Jun 4, 2023 by avibootz
...