int _fileno(FILE *stream ); ----->Gets the file descriptor associated with a stream.(用来取得参数stream指定的文件流所使用的文件描述符)
#include<stdio.h>
返回值:某个数据流的文件句柄
DEMO:MSDN上的例子
#include <stdio.h>
#include <process.h>
int main()
{
printf("The file descriptor for stdin is %d\n",_fileno(stdin));
printf("The file descriptor for stdout is %d\n",_fileno(stdout));
printf("The file descriptor for stderr is %d\n",_fileno(stderr));
system("pause");
return 0;
}
DEMO2:
#include <stdio.h>
#include <process.h>
int main()
{
FILE *fp=NULL;
int file_handle;
fp=fopen("fileno.c","r");
if (fp==NULL)
{
fprintf(stderr,"it's a error!\n");
getchar();
return -1;
}
file_handle=_fileno(fp);
printf("fd=%d\n",file_handle);
fclose(fp);
fp=NULL;
system("pause");
return 0;
}
【FROM MSDN &&百科】