是否可以在单个 C 程序中的多个终端窗口上输出? [英] Is it possible to output on multiple terminal windows within a single C program?

查看:35
本文介绍了是否可以在单个 C 程序中的多个终端窗口上输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想做的是为单个程序提供两个输出终端窗口.一个是显示程序正在执行的操作的日志,第二个是显示值表之类的东西.这些终端的所有输出都将由程序本身生成.这可以用 stdio 在 C 中做吗?

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?

我意识到这可能更适合 GUI 或 ncurses,但我仍然很好奇这是否可以无论如何完成.

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.

可能还应该提到我在 linux(特别是 xubuntu)上这样做.

Should probably also mention I'm doing this on linux (xubuntu specifically).

推荐答案

不是以任何可移植的方式,而是在 Linux 上,/dev/pts 是一个包含所有打开的 ttys 的目录,所以写作一些不同的 /dev/pts/ 文件会将输出放在多个终端上.

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.

这篇关于是否可以在单个 C 程序中的多个终端窗口上输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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