-
Rust연습_H가 같은줄에 출력에서 앞으로 계속 쌓임.코딩Coding/Rust연습 2022. 8. 14. 00:06728x90
use std::io::Write; use std::time::Duration; fn main() { let ch = 'H' as u8; for _ in 0..20 { let buff = vec![ch]; std::io::stdout().write(&buff).unwrap(); std::io::stdout().flush().unwrap(); std::thread::sleep(Duration::from_millis(1000)); } }
결과
cargo run Compiling char v0.1.0 (/Users/globalyoung/Documents/test/rust/char) Finished dev [unoptimized + debuginfo] target(s) in 0.17s Running `target/debug/char` HHHHHHHHHHHH^Z [3] + 5989 suspended cargo run
https://stackoverflow.com/questions/63590925/how-to-do-non-buffered-writes-to-stdout
반응형'코딩Coding > Rust연습' 카테고리의 다른 글
rust연습❤️let mut p: f64 = 16us.pow(2) as f64; (0) 2022.09.12 Rust☆연습_Traits_part2 (0) 2022.09.11 Rust☆연습(Traits)_part1 (0) 2022.09.11 러스트연습숫자가 0부터 계속 올라감 계속 그 자리에서 출력 (0) 2022.08.14 Rust연습❤️물어보고 출력 무한 loop (0) 2022.08.14 Rust Machine learning code 불완전함 (0) 2022.08.13 러스트연습❤️ 뭔가 제자리에서 출력되는거 (0) 2022.08.13 Rust연습❤️“rust spinning rod animation in text” Code Answer (0) 2022.08.13