Pure Programmer
Blue Matrix


Cluster Map

Project: Punchcard Message

Write a program that takes a message on the command line and then prints it out as a bit pattern similar to an old-style punchcard. Eight rows will be output with each column in the output representing the bit pattern for one byte in the message. The least significant bit should be at the bottom and the most significant bit should be at the top. Use the LEFT HALF BLOCK Unicode character ('\u258c') to represent a bit that is on in the byte. Use a space for bits that are off.

Output
$ rustc PunchcardMessage.rs error: unknown format trait `s` --> PunchcardMessage.rs:16:38 | 16 | println!("{}", format!("Syntax: {0:s} message", utils::program_name().expect("program name should not be empty!"))); | ^ | = note: the only appropriate formatting traits are: - ``, which uses the `Display` trait - `?`, which uses the `Debug` trait - `e`, which uses the `LowerExp` trait - `E`, which uses the `UpperExp` trait - `o`, which uses the `Octal` trait - `p`, which uses the `Pointer` trait - `b`, which uses the `Binary` trait - `x`, which uses the `LowerHex` trait - `X`, which uses the `UpperHex` trait error[E0425]: cannot find value `args` in this scope --> PunchcardMessage.rs:13:5 | 13 | if args.len() == 2 { | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::env::args; | error[E0425]: cannot find value `args` in this scope --> PunchcardMessage.rs:14:15 | 14 | message = &(args[1]); | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::env::args; | error[E0425]: cannot find function `exit` in this scope --> PunchcardMessage.rs:17:3 | 17 | exit(1); | ^^^^ not found in this scope | help: consider importing this function | 7 + use std::process::exit; | error[E0412]: cannot find type `usuze` in this scope --> PunchcardMessage.rs:28:22 | 28 | mask = ((mask) as usuze >> 1) as isize; | ^^^^^ help: a builtin type with a similar name exists: `usize` error[E0423]: expected function, found builtin type `u32` --> PunchcardMessage.rs:24:23 | 24 | let c2:char = if (u32(c) & mask) != 0 { LEFT_HALF_BLOCK } else { ' ' }; | ^^^ not a function error: aborting due to 6 previous errors Some errors have detailed explanations: E0412, E0423, E0425. For more information about an error, try `rustc --explain E0412`.

Solution