fileno

filenoは、指定されたファイルポインタの指すストリームのファイルディスクリプタを返す。

Man page of FERROR

stdio.hだが、標準関数一覧には何故かない。
fileno.cで、

stdin, stdout, stderr, そして新たに開いた"test.txt"のファイルディスクリプタを出力。

$ vi fileno.c 
$ gcc fileno.c -o fileno
$ ./fileno 
fileno stdin = 0
fileno stdout = 1
fileno stderr = 2
fileno fp = 3
$

0, 1, 2, 3, と割り振られている。

Sample/unixsyscall/fileno/fileno/src/fileno at master · bg1bgst333/Sample · GitHub