Sorry if this is a very noob question, but i'm just starting with ncurses (and C++).
I'm trying to call a system command inside a ncurses code (for the example, anything will work) and to store the output in a variable, not displaying it until i print it, but when i create a variable with the system() output, it is printed automatically in the screen.
This is my code so far:
#include <iostream>
#include <string>
#include <ncurses.h>
using namespace std;
string g;
int main()
{
initscr();
int h, w;
getmaxyx(stdscr, h, w);
cbreak();
refresh();
g=system("date");
WINDOW* w1_b = newwin(h, w/2, 0, 0);
box(w1_b, 0 , 0);
WINDOW* w2_b = newwin(h/2, w/2, 0, w/2);
box(w2_b, 0 , 0);
WINDOW* w3_b = newwin(h/2, w/2, h/2, w/2);
box(w3_b, 0 , 0);
wrefresh(w1_b);
wrefresh(w2_b);
wrefresh(w3_b);
WINDOW* w1 = newwin(h-2, (w/2)-2, 1, 1);
WINDOW* w2 = newwin((h/2)-2, (w/2)-2, 1, (w/2)+1);
WINDOW* w3 = newwin((h/2)-2, (w/2)-2, (h/2)+1, (w/2)+1);
mvwprintw(w1, 1, 1, "Window 1");
mvwprintw(w2, 1, 1, "Window 2");
mvwprintw(w3, 1, 1, "Window 3");
wrefresh(w1);
wrefresh(w2);
wrefresh(w3);
getch();
endwin();
return 0;
}
Now, when g=system("date");
is executed, the date is automatically printed in the screen, even if i'm storing it inside a variable (g in this case), Any idea of what can be wrong?