1.#include <unistd.h>
是POSIX标准定义的unix类系统定义符号常量的头文件,包含了许多UNIX系统服务的函数原型
例如:read函数、write函数和getpid函数
2.#include <fcntl.h >
定义了很多宏和open,fcntl函数原型
3.#include <stdlib.h>
stdlib.h是C标准函数库的头文件,声明了数值与字符串转换函数, 伪随机数生成函数, 动态内存分配函数, 进程控制函数等公共函数。 C++程序应调用等价的cstdlib头文件.
例:malloc()、calloc()、realloc()、free()、system()、atoi()、atol()、rand()、 srand()、exit()等等。
4.#include <conio.h >
conio.h不是C标准库中的头文件。conio是Console Input/Output(控制台输入输出)的简写,其中定义了通过控制台进行数据输入和数据输出的函数,主要是一些用户通过按键盘产生的对应操作。
例:getch()函数等等。
5.#include <sys/stat.h >
stat.h头文件,轻松获取文件属性,以前还为了获取文件的长度,费劲从头读取一遍,一个一个字节的算。
int stat(const char *restrict pathname,struct stat *restrict buf);int fstat(int fields,struct stat *buf);int lstat(const char *restrict pathname,struct stat *restrict buf);
返回值:若成功则返回0,失败则返回-1。一旦给出pathname,stat函数就返回与此命名文件有关的信息结构,fstat函数获取已在描述符fields上打开文件的有关信息。lstat函数类似于stat.但是当命名的文件是一个符号链接时,lstat返回该符号链接的有关信息,而不是由该符号链接引用文件的信息。第二个参数buf是指针,它指向一个我们必须提供的结构,这些函数填写由buf指向的结构。该结构的实际定义可能随实现有所不同.stat结构体如下:
struct stat{ mode_t st_mode; //文件类型和权限信息 ino_t st_ino; //i结点标识 dev_t st_dev; //device number (file system) dev_t st_rdev; //device number for special files nlink_t st_nlink; //符号链接数 uid_t st_uid; //用户ID gid_t st_gid; //组ID off_t st_size; //size in bytes,for regular files time_t st_st_atime; //最后一次访问的时间 time_t st_mtime; //文件内容最后一次被更改的时间 time_t st_ctime; //文件结构最后一次被更改的时间 blksize_t st_blksize; //best I/O block size blkcnt_t st_blocks; //number of disk blocks allocated }; |