Example in Rust for reference:
use std::{io::{self, Write}, thread, time::Duration};
fn main() {
for i in 0..=100 {
let width = 40;
let filled = i * width / 100;
let empty = width - filled;
print!(
"\r[{}{}] {:3}%",
"#".repeat(filled),
" ".repeat(empty),
i
);
io::stdout().flush().unwrap();
thread::sleep(Duration::from_millis(50));
}
println!(); // final newline
}
Example in Rust for reference: