首页 > 解决方案 > 我可以打印到始终显示的 Windows 控制台数据吗?

问题描述

我有一个控制台程序,我想在前几行中显示一些状态,同时保持其余行的普通输入/输出日志记录行为。

我试图在这里说明它:

+-----------------------------+  <-+
/ state1: abcdef              /    | // this always stays at the top of the console
/ state2: 012345              /    | // this is the behavior that deviates from normal
+-----------------------------+  <-+ 
1st input  ^                       <-+ 
2nd input  |                         | // this scrolls upward as usual for the console
3rd input  |                         | // displaying past inputs/outputs
4th input  |                       <-+
5th in_                          <-- // normal console input + carot

我尝试输出整个控制台窗口的内容来模拟这一点,但它不会立即更新,视觉上会撕裂,而且通常很挑剔,因为它取决于控制台窗口的大小。

是否可以让控制台或类似窗口的控制台之类的东西来执行这种行为?如果滚动变得不可能,那也没关系。

标签: c++windowsconsole

解决方案


推荐阅读