#include <stdio.h> #include <term.h> #include <curses.h> #include <stdlib.h> int main() { setupterm("unlisted", fileno(stdout), (int *)0); printf("Done.\n"); exit(0); }
运行它,我得到以下结果:
./badterm 'unlisted': unknown terminal type.
根据setupterm函数定义,它必须返回0:“terminfo数据库中没有匹配的条目”。相反,程序终止。为什么?
看起来是你让它这么做的。从 man setupterm
man setupterm
If errret is null, setupterm prints an error message upon finding an error and exits. Thus, the simplest call is: setupterm((char *)0, 1, (int *)0); which uses all the defaults and sends the output to stdout.
errret (三)参数。
errret