Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 views
in Technique[技术] by (71.8m points)

stdio - Is it possible to output on multiple terminal windows within a single C program?

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).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...