这是《Linux 编程入门》一书中的示例程序:
#include <stdio.h>
#include <term.h>
#include <curses.h>
#include <stdlib.h>
int main()
{
setupterm("未列出", fileno(stdout), (int *)0);
printf("完成。\n");
退出(0);
}
运行它,我得到这个结果:
./坏术语 “未列出”:未知的终端类型。
根据setupterm函数定义,它必须返回0:“terminfo数据库中没有匹配的条目”。相反,程序会终止。为什么?
看来是你要求它这样做的。从man setupterm我的机器上:
Run Code Online (Sandbox Code Playgroud)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.
据推测,如果您想自己处理任何错误返回,则必须为(第三个)参数提供非 NULL 指针值errret。
| 归档时间: |
|
| 查看次数: |
1061 次 |
| 最近记录: |