Question

  • Platform: Linux 3.2.0 x86 (Debian Wheezy)
  • Compiler: GCC 4.7.2 (Debian 4.7.2-5)

I am writing a program that requires advanced terminal control that is provided by ncurses but I cannot get my program to print anything to stdscr. For example if I compiled the following code I would not see "Testing.. Testing" on the screen. I have used ncurses before and I have never encountered such a problem. I do not know if this is relevant or not but I am running a fresh install of Debian (I literally installed it a couple of hours ago).

#include <ncurses.h>

int main()
{
    initscr();
    printw("Testing... Testing");
    refresh();
    return;
}

Also the above progam was compiled with,

gcc --all-warnings --extra-warnings -std=c11 filename.c -lncurses
Was it helpful?

Solution

If you want to see the text, maybe you should keep the program running when you're printing it.

#include <ncurses.h>

int main()
{
    initscr();
    printw("Testing... Testing");
    refresh();
    getch(); // Wait the user input in order to keep the program active and showing text.
    endwin(); // Terminate the window to clean all memory allocations.
    return;
}

You can get more informations on the ncurses "hello world": http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top