Project: Aligning Characters and Strings with printf()
Write a program that demonstrates the formatting of characters and strings using printf() and/or sprintf() style output. Your program should reproduce the output shown using the following variables:
- c1 = "C" (or 'C' in C++)
- c2 = "-"
- c3 = 51
- c4 = 80
- c5 = 0x4f
- s = "Boba Fett"
Output
$ rustc AligningCharactersAndStringsWithPrintf.rs
error[E0423]: expected function, found builtin type `u32`
--> AligningCharactersAndStringsWithPrintf.rs:15:34
|
15 | println!("{}", sprintf("c1: %c",u32(c1)));
| ^^^ not a function
error[E0425]: cannot find function `sprintf` in this scope
--> AligningCharactersAndStringsWithPrintf.rs:15:17
|
15 | println!("{}", sprintf("c1: %c",u32(c1)));
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `ord` in this scope
--> AligningCharactersAndStringsWithPrintf.rs:16:34
|
16 | println!("{}", sprintf("c2: %c",ord(c2)));
| ^^^ not found in this scope
error[E0425]: cannot find function `sprintf` in this scope
--> AligningCharactersAndStringsWithPrintf.rs:16:17
|
16 | println!("{}", sprintf("c2: %c",ord(c2)));
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `sprintf` in this scope
--> AligningCharactersAndStringsWithPrintf.rs:17:17
|
17 | println!("{}", sprintf("c3: %c",c3));
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `sprintf` in this scope
--> AligningCharactersAndStringsWithPrintf.rs:18:17
|
18 | println!("{}", sprintf("c4: %c",c4));
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `sprintf` in this scope
--> AligningCharactersAndStringsWithPrintf.rs:19:17
|
19 | println!("{}", sprintf("c5: %c",c5));
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `sprintf` in this scope
--> AligningCharactersAndStringsWithPrintf.rs:20:17
|
20 | println!("{}", sprintf("s: %s",s));
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `sprintf` in this scope
--> AligningCharactersAndStringsWithPrintf.rs:21:17
|
21 | println!("{}", sprintf("s: %.4s",s));
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `sprintf` in this scope
--> AligningCharactersAndStringsWithPrintf.rs:22:17
|
22 | println!("{}", sprintf("s: |%10.4s|",s));
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `sprintf` in this scope
--> AligningCharactersAndStringsWithPrintf.rs:23:17
|
23 | println!("{}", sprintf("s: |%-10.4s|",s));
| ^^^^^^^ not found in this scope
error: aborting due to 11 previous errors
Some errors have detailed explanations: E0423, E0425.
For more information about an error, try `rustc --explain E0423`.