Pure Programmer
Blue Matrix


Cluster Map

Project: Morse Code

Write a program that converts a text message passed from the command line into [[Morse_code|Morse code]]. Use a Unicode Middle Dot (U+00B7) for dots and a Unicode Minus Sign (U+2212) for dashes. Use a space to separate letters and three spaces to separate words.

Output
$ rustc MorseCode.rs error[E0425]: cannot find function `exit` in this scope --> MorseCode.rs:81:3 | 81 | exit(1); | ^^^^ not found in this scope | help: consider importing this function | 8 + use std::process::exit; | error[E0308]: mismatched types --> MorseCode.rs:86:14 | 86 | while m <= (args.len() - 1) { | - ^^^^^^^^^^^^^^^^ expected `isize`, found `usize` | | | expected because this is `isize` | help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit | 86 | while m <= ((args.len() - 1)).try_into().unwrap() { | + +++++++++++++++++++++ error[E0277]: the type `[String]` cannot be indexed by `isize` --> MorseCode.rs:91:18 | 91 | for c in args[m].chars() { | ^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[String]>` is not implemented for `isize` = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required for `Vec<String>` to implement `Index<isize>` error[E0423]: expected function, found builtin type `u32` --> MorseCode.rs:92:22 | 92 | let mut cp:i32 = u32(c); | ^^^ not a function error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0308, E0423, E0425. For more information about an error, try `rustc --explain E0277`. $ rustc MorseCode.rs error[E0425]: cannot find function `exit` in this scope --> MorseCode.rs:81:3 | 81 | exit(1); | ^^^^ not found in this scope | help: consider importing this function | 8 + use std::process::exit; | error[E0308]: mismatched types --> MorseCode.rs:86:14 | 86 | while m <= (args.len() - 1) { | - ^^^^^^^^^^^^^^^^ expected `isize`, found `usize` | | | expected because this is `isize` | help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit | 86 | while m <= ((args.len() - 1)).try_into().unwrap() { | + +++++++++++++++++++++ error[E0277]: the type `[String]` cannot be indexed by `isize` --> MorseCode.rs:91:18 | 91 | for c in args[m].chars() { | ^ slice indices are of type `usize` or ranges of `usize` | = help: the trait `SliceIndex<[String]>` is not implemented for `isize` = help: the trait `SliceIndex<[T]>` is implemented for `usize` = note: required for `Vec<String>` to implement `Index<isize>` error[E0423]: expected function, found builtin type `u32` --> MorseCode.rs:92:22 | 92 | let mut cp:i32 = u32(c); | ^^^ not a function error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0308, E0423, E0425. For more information about an error, try `rustc --explain E0277`.

Solution