FILE I/O

来源:互联网 发布:男款汉服款式知乎 编辑:程序博客网 时间:2024/05/01 16:24
1、od -c file.hole  此命令用来查看文件的内容,其中-c的意思是以字符的形式查看。
2、 ls -ls file.hole file.nohole 此命令用来比较两个文件的大小,此处是用来比较有hole和没有hole文件的大小。
3、
4、#include <unistd.h>
     ssize_t read(int filedes, void *buf, size_t nbytes);
     的原型为:
      int read(int filedes, char *buf, unsigned nbytes);
     当nbytes为负数时,函数返回-1.
5、实际上普通的unix shell提供了一种方法来打开一个文件供标准输入使用,创建了一个文件供标准输出使用,这就阻止了程序打开输入输出文件。
6、#include <unistd.h> 
     int dup(int filedes);                           //文件描述符复制函数
     int dup2(int filedes, int filedes2);         //文件描述符复制函数
     Both return: new file descriptor if OK, –1 on error
     注:复制出的两个文件描述符公用一个文件表,当然也公用一个v-node table