防止控制台输出和书面文本混合 [英] Prevent mixing of console output and written text

查看:97
本文介绍了防止控制台输出和书面文本混合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++控制台应用程序打印一些输出不断,同时它也接受命令(使用 std :: cin )从用户 - 输出和输入发生在单独的线程。

如果在某些输出出现时写入文本,则写入的文本与应用程序输出混合。如何防止此行为?

I have a C++ console application that prints some output constantly while it also accepts commands (using std::cin) from the user - output and input happen in separate threads.
If I write a text while some output appears the written text is mixed with application output. How can I prevent this behaviour?

要解决这个问题问题,我需要在上面一行显示文本键入的行。我会在Minecraft Bukkit服务器的解决方案中激发自己 - 但是我需要C ++的解决方案。

To solve this problem, I need to display the program one line above the line where the text is typed. I'd inspire myself in Minecraft Bukkit server's solution - however I need the same for C++.

推荐答案

有一个名为pdcurses的ncurses的Windows端口。但是如果你使用visual studio有一个简单的函数提供SetConsoleCursorPosition()

There's a windows port of ncurses called pdcurses. But if you are using visual studio there's a simple function provided called SetConsoleCursorPosition()

这篇关于防止控制台输出和书面文本混合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆