这是“Beginning Linux Programming”一书中的示例程序:
#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数据库中没有匹配的条目” . 而不是这个,程序终止 . 为什么?
1 回答
看起来你要求它这样做 . 从
man setupterm
在我的机器上:setupterm((char *)0,1,(int *)0);
它使用所有默认值并将输出发送到stdout .
据推测,如果您想自己处理任何错误返回,则必须为
errret
(第三个)参数提供非NULL指针值 .