2

これは「BeginningLinuxProgramming」の本のサンプルプログラムです。

#include <stdio.h>
#include <term.h>
#include <curses.h>
#include <stdlib.h>

int main()
{{
    setupterm( "unlisted"、fileno(stdout)、(int *)0);
    printf("完了。\n");
    exit(0);
}

それを実行すると、次の結果が得られます。

./badterm
'unlisted':不明な端末タイプ。

setupterm関数の定義によると、「terminfoデータベースに一致するエントリがありません」という0を返す必要があります。これの代わりに、プログラムは終了します。なんで?

4

1 に答える 1

3

あなたがそうするように頼んだようです。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(3番目の)パラメーターにNULL以外のポインター値を指定する必要があります。

于 2010-06-07T11:53:15.613 に答える