問題描述
我正在為 Mac OS X 編寫一個命令行工具來處理一堆文件.我想向用戶展示當前正在處理的文件,但不希望大量文件污染終端窗口.
I'm writing a command-line tool for Mac OS X that processes a bunch of files. I would like to show the user the current file being processed, but do not want a bazillion files polluting the terminal window.
相反,我想使用一行來輸出文件路徑,然后將該行重復用于下一個文件.是否有一個字符(或其他一些代碼)輸出到 std::cout
來完成這個?
Instead I would like to use a single line to output the file path, then reuse that line for the next file. Is there a character (or some other code) to output to std::cout
to accomplish this?
另外,如果我想將此工具重新定位到 Windows,兩個平臺的解決方案是否相同?
Also, if I wanted to re-target this tool for Windows, would the solution be the same for both platforms?
推薦答案
" " 應該適用于 Windows 和 Mac OS X.
" " should work for both windows and Mac OS X.
類似于:
std::cout << "will not see this
will see this" << std::flush;
std::cout << std::endl; // all done
這篇關于倒帶 std::cout 回到行首的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!