fileno函数
2016-06-21 10:28
302 查看
函数名称:fileno(在VC++6.0下为_fileno[1] )
函数原型:int _fileno( FILE *stream );
函数功能:fileno()用来取得参数stream指定的文件流所使用的文件描述符
返回值:某个数据流的文件描述符
头文件:stdio.h
相关函数:open,fopen,fclose
#include <stdio.h>
int main( void )
{
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 ) );
}
输出:
The file descriptor for stdin is 0
The file descriptor for stdout is 1
The file descriptor for stderr is 2
程序示例2
#include <stdio.h>
int main(void)
{
FILE *fp;
int fd;
fp = fopen("/etc/passwd", "r");
fd = fileno(fp);
printf("fd = %d\n", fd);
fclose(fp);
return 0;
}
函数原型:int _fileno( FILE *stream );
函数功能:fileno()用来取得参数stream指定的文件流所使用的文件描述符
返回值:某个数据流的文件描述符
头文件:stdio.h
相关函数:open,fopen,fclose
#include <stdio.h>
int main( void )
{
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 ) );
}
输出:
The file descriptor for stdin is 0
The file descriptor for stdout is 1
The file descriptor for stderr is 2
程序示例2
#include <stdio.h>
int main(void)
{
FILE *fp;
int fd;
fp = fopen("/etc/passwd", "r");
fd = fileno(fp);
printf("fd = %d\n", fd);
fclose(fp);
return 0;
}
相关文章推荐
- struct结构体中的点
- C++ - PAT - 1040. 有几个PAT(25)
- 小米note花屏-降级-remote partition table doesn t exist问题的处理和感叹
- 士兵杀敌(一)
- ECharts · Doc
- Linux 下的两个特殊的文件 -- /dev/null 和 /dev/zero
- java中的Stack的使用
- iOS NSDate 使用
- .NET实现简易的文件增量备份程序
- 什么是数据抽取 --全量抽取、增量抽取
- 查看cpu和内存使用情况
- iOS 数据持久化之覆盖式存储(Plist ,Preference,归档)
- Java线程和多线程(一)——线程的基本概念
- Java线程和多线程(一)
- Spring 的AOP--spring框架动态实现AOP
- Sumblime Text 2 常用插件以及安装方法
- Sort(归并)
- Html语言学习(二)
- Deep Learning(深度学习)之(十)神经网络在机器学习分类任务中的应用
- C++之cin.eof, cin.bad, cin.good, cin.fail, cin.clear