Search code examples
c++cconsolewindowncurses

NCurses: new window not showing up


I'm following the example presented in the book "Programmer's Guide to NCurses" by Dan Gookin for creating a second window. Here's the code:

#include <ncurses/ncurses.h>

int main()
{
    WINDOW* second_window;

    initscr();

    addstr("Origian window, stdscr.\n");
    refresh();
    getch();

    second_window = newwin(0, 0, 0, 0);

    if(second_window = NULL)
    {
        addstr("Unable to create new window...\n");
        endwin();
        return 1;
    }

    waddstr(second_window, "This is the second window!!!\n");

    getch();
    wrefresh(second_window);
    endwin();

    return 0;
}

However, no new window is showing up, and I'm not getting any error either.


Solution

  • I have used "=" instead of "==" in a comparison.