println! error: expected a literal / format argument must be a string literal

This should work:

fn main() {
    let c = "hello";
    println!("{}", c);
}

The string "{}" is a template where {} will be replaced by the next argument passed to println!.

Leave a Comment