I'd like to write a simple program using ncurses for displaying some data. I would then like for the program to write to stdout in such a way that I can then use a pipe (|) on the command line to pipe some data out.
My current attempt doesn't work. I can see the "GOT HERE"'s in a file using '>', but there's a whole bunch of other stuff. The program also exits immediately.
#include <stdio.h>
#include <ncurses.h>
int main(int _argc, char ** _argv)
{
initscr(); /* Start curses mode */
printw("Hello World !!!"); /* Print Hello World */
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
printf("GOT HERE");
endwin(); /* End curses mode */
printf("GOT HERE");
return 0;
}
This is the final output using >
^[[?1049h^[[1;29r^[(B^[[m^[[4l^[[?7h^[[H^[[2JHello World !!!^MGOT HERE^[[29;1H^[[?1049l^M^[[?1l^[>GOT HERE
Is it possible to use stdout
through a pipeline and ncurses at the same time?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…