Sometimes, we want to print symbol "
.
In this case, we have to type \
before "
.
For example:
fn main() {
println!("\"");
}
Output:
"
There are other special symbols such as {
, }
and \
that require special forms to print them.
fn main() {
println!("{{");
println!("}}");
println!("\\");
}
Output:
{
}
\
These symbols may look like this when they are combined with other texts:
fn main() {
println!("{{}} is a pair of \"braces\". \\(o.o)/");
}
Output:
{} is a pair of "braces". \(o.o)/
➡️ Next: Printing Numbers
📘 Back: Table of contents