The main example of ncurses - in debugging, I get: "Terminal opening error: unknown."

by executing some basic examples in ncurses libreries, I get some problems.

Actually, I don’t understand what I expect (the message is printed), and it’s being debugged, from eclipse I get (in the console area) “Error opening terminal: unknown”.

Executes the code:

#include <unistd.h> #include <stdlib.h> #include <ncurses.h> int main() { initscr(); move(5,15); printw("%s", "Hello world!"); refresh(); endwin(); exit(EXIT_SUCCESS); } 

Compiler options, as indicated in the Eclipse console in the Build project command:

 make all Building file: ../source/Curses_01.c Invoking: GCC C Compiler gcc -Incurses -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"source/Curses_01.d" -MT"source/Curses_01.d" -o"source/Curses_01.o" "../source/Curses_01.c" Finished building: ../source/Curses_01.c Building target: Curses_01 Invoking: GCC C Linker gcc -o"Curses_01" ./source/Curses_01.o -lcurses Finished building target: Curses_01 

Thanks to everyone in advance!

+6
source share
1 answer

You will get a string printed. The problem is that the program will exit the program immediately. This will clear the screen and return it to its previous state. This happens very quickly, of course, so you don’t see anything.

The solution is to wait for the key to be pressed before exiting. You can do this with getch() :

 /* ... */ refresh(); getch(); endwin(); exit(EXIT_SUCCESS); 

An Eclipse problem occurs because of the terminal provided by Eclipse for the application. NCurses will not recognize him. I do not use Eclipse, so I do not know exactly how to do this, but you should find some parameter that allows you to run the application inside the full terminal (for example, in xterm, Konsole, Gnome Terminal, etc.),

+2
source

All Articles