如何清除命令行? [英] How to clear the command line?
本文介绍了如何清除命令行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 C/C++ 标准库中是否有 Rust 等价于 system
函数?具体来说,我正在尝试使用 cls
来清除命令行.
Is there a Rust equivalent to the system
function in the C/C++ standard library? Specifically I am trying to use cls
to clear the command line.
推荐答案
你可以使用 C 的system
函数 通过libc
箱子.但幸运的是有一个更好的方法:std::process::Command
.
You could use C's system
function through the libc
crate. But fortunately there's a much better way: std::process::Command
.
调用 cls
的一种快速而肮脏的方法是
A quick and dirty way to call cls
would be
if std::process::Command::new("cls").status().unwrap().success() {
println!("screen successfully cleared");
}
这篇关于如何清除命令行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文