#include sys/type.h stat.h unistd.h fnctl.h

48 篇文章 1 订阅
<sys/type.h>
此头文件还包含适当时应使用的多个基本派生类型。尤其是以下类型更为重要:

  clock_t 表示系统时间(以时钟周期为单位)。
  dev_t 用于设备号。
  off_t 用于文件大小和偏移量。
  ptrdiff_t 是一种带符号整型,用于对两个指针执行减法运算后所得的结果。
  size_t 反映内存中对象的大小(以字节为单位)。
  ssize_t 供返回字节计数或错误提示的函数使用。
  time_t 以秒为单位计时。
  所有这些类型在 ILP32 编译环境中保持为 32 位值,并会在 LP64 编译环境中增长为 64 位值。
这里写图片描述

位置在哪儿呢?
find /usr/include -name “types.h”
里面有一项 /usr/include/x86_64-linux-gnu/sys/types.h
这里写图片描述

<sys/stat.h>
是unix/linux系统定义文件状态所在的伪标准头文件
  dev_t     st_dev     Device ID of device containing file.
  ino_t     st_ino     File serial number.
  mode_t    st_mode    Mode of file (see below).
  nlink_t   st_nlink   Number of hard links to the file.
  uid_t     st_uid     User ID of file.
  gid_t     st_gid     Group ID of file.
  dev_t     st_rdev    Device ID (if file is character or block special).
  off_t     st_size    For regular files, the file size in bytes.
     For symbolic links, the length in bytes of the pathname contained in the symbolic link.
     For a shared memory object, the length in bytes.
     For a typed memory object, the length in bytes.
     For other file types, the use of this field is unspecified.
 time_t    st_atime   Time of last access.
 time_t    st_mtime   Time of last data modification.
 time_t    st_ctime   Time of last status change.
 int    chmod(const char *, mode_t);
 int    fchmod(int, mode_t);
 int    fstat(int, struct stat *);
 int    lstat(const char *restrict, struct stat *restrict);
 int    mkdir(const char *, mode_t);
 int    mkfifo(const char *, mode_t);
 int    mknod(const char *, mode_t, dev_t);
 int    stat(const char *restrict, struct stat *restrict);
 mode_t umask(mode_t);

使用stat函数最多的可能是ls-l命令,用其可以获得有关一个文件的所有信息。
一般头文件在/usr/include下面,这里是标准C程序头文件,如果你的头文件前加了

<sys/unistd.h>
#include    <unistd.h>

符号常量

是POSIX标准定义的unix类系统定义符号常量的头文件,包含了许多UNIX系统服务的函数原型,例如read函数、write函数和getpid函数

unistd.h在unix中类似于window中的windows.h!
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif

unistd.h含有的常量与函数:

ssize_t      read(int, void *, size_t);
int         unlink(const char *);
ssize_t     write(int, const void *, size_t);
int          usleep(useconds_t);
unsigned     sleep(unsigned);

int          access(const char *, int);
unsigned     alarm(unsigned);
int          chdir(const char *);
int          chown(const char *, uid_t, gid_t);
int          close(int);
size_t      confstr(int, char *, size_t);
void        _exit(int);
pid_t        fork(void);

NULL           // Null pointer
SEEK_CUR    // Set file offset to current plus offset.
SEEK_END    // Set file offset to EOF plus offset.
SEEK_SET    // Set file offset to offset.
<sys/fnctl.h>

linux 文件操作/文件描述符的头文件
相关函数 open,fcntl,shutdown,unlink,fclose、close(关闭文件)

<sys/cdef.h>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值