是否可以在单个 C 程序中在多个终端窗口上输出?
基本上我想做的是为单个程序提供两个输出终端窗口。一个将显示程序正在执行的操作日志,第二个将显示类似值表的内容。这些终端的所有输出都将由程序本身生成。这可以用 C 语言用 stdio 实现吗?
我意识到这可能更适合 GUI 或 ncurses,但我仍然很好奇这是否可以完成。
编辑:也许还应该提到我是在linux(特别是xubuntu)上这样做的。
Basically what I'd like to do is have two output terminal windows for a single program. One would be displaying a log of actions being taken by the program, and the second would be displaying something like a table of values. All of the output for these terminals would be generated by the program itself. Is this possible to do in C with stdio?
I realise this is probably something more suited for a GUI or ncurses, but I'm still curious as to whether this can be done regardless.
Edit: Should probably also mention I'm doing this on linux (xubuntu specifically).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是以任何可移植的方式,但在 Linux 上,
/dev/pts
是一个包含所有打开的 tty 的目录,因此写入几个不同的/dev/pts/< /code> 文件会将输出放在多个终端上。
Not in any portable way, but on Linux,
/dev/pts
is a directory containing all of the open ttys, so writing to a few diferent/dev/pts/<n>
files would put output on multiple terminals.