open函数相关的:  /* open 是系统调用 返回的是文件句柄*/

#include <sys/stat.h>
#include <fcntl.h> int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);

  

fopen函数相关的:   /* open是ANSIC标准中的C语言库函数,在不同的系统中应该调用不同的内核api  */

FILE *fopen(const char *path, const char *mode);  

FILE *fdopen(int fd, const char *mode);  

FILE *freopen(const char *path, const char *mode, FILE *stream);

  

函数说明:fileno()用来取得参数stream 指定的文件流所使用的文件描述词.

void clearerr(FILE *stream);  

int feof(FILE *stream);  

int ferror(FILE *stream);  

int fileno(FILE *stream);

  

实例:

#include <stdio.h>  

int main(int argc, char **argv)  

{
FILE * fp;
int fd;
fp = fopen("/etc/passwd", "r");
fd = fileno(fp);
//等价于
  //fd=open("etc/passwd",RD_ONLY);
printf("fd=%d\n", fd);
fclose(fp);
return 0;
}

  

  

最新文章

  1. HTML和CSS的复习总结
  2. oracle 触发器学习
  3. [Linux 性能检测工具]VMSTAT
  4. [No000057]一个人默默背单词,小心被传染哦
  5. jQuery升级踩坑大全
  6. 加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: FINAL
  7. [Html5]sessionStorage和localStorage常见操作
  8. Linux下安装FTP
  9. ios警告:Category is implementing a method which will also be implemented by its primary class 引发的相关处理
  10. poj 3468 A Simple Problem with Integers【线段树区间修改】
  11. Android APK反编译 apktool使用教程
  12. 利用NPOI将EXCEL转换成HTML的C#实现
  13. 【Android 应用开发】 ActionBar 基础
  14. ubuntu 18.04 配置远程ssh/远程ftp/远程vnc登陆
  15. Oracle XMLTYPE数据类型创建及插入
  16. php 解密$OOO0O0O00=__FILE__
  17. 使用Java创建指定大小的空文件夹
  18. TRIO-basic指令--MOVEMODIFY
  19. Effective Java 第三版——45. 明智审慎地使用Stream
  20. 【Go命令教程】14. go env

热门文章

  1. ann搜索算法(Approximate Nearest Neighbor)
  2. sql导入数据库
  3. Solaris作业管理
  4. Hadoop 源码阅读技巧
  5. [Node.js] 關於 console.log 的格式化輸出
  6. Mataplotlib事例操作
  7. git 安装及命令
  8. static 静态域 类域 静态方法 工厂方法 he use of the static keyword to create fields and methods that belong to the class, rather than to an instance of the class 非访问修饰符
  9. 使用注解来构造IoC容器-转
  10. MFC获取电脑硬盘序列号(附源代码)