请问关于linux下创建文件的问题
在一本书上看到以下代码
在linux的终端上输入:
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
int main()
{
int fd;
fd=creat("/home/4-5file",S_IRUSR); /*所有者具有只读权限*/
system("ls /home/4-5file -l"); /*执行ls命令*/
return 0;
}
对于creat就需要 include<fcntl.h>
对于system就需要 include<sys/stat.h>
(1)那么include<sys/types.h>的作用是什么呢?(我把它删除也能正常运行呀)
(2)尝试过用#include<system>来代替include<sys/types.h>,include<sys/stat.h>,结果程序运行出错,其实include<system>是包含system函数库的,那么sys又代表什么意思呢?(也就是说sys不是包含system函数库的吗)
(3)如果我想查找相关的头文件包含了哪些函数的话,比如include<sys/stat.h>,在linux下能不能查到呢?或者能怎么做呢?
谢谢
在linux的终端上输入:
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
int main()
{
int fd;
fd=creat("/home/4-5file",S_IRUSR); /*所有者具有只读权限*/
system("ls /home/4-5file -l"); /*执行ls命令*/
return 0;
}
对于creat就需要 include<fcntl.h>
对于system就需要 include<sys/stat.h>
(1)那么include<sys/types.h>的作用是什么呢?(我把它删除也能正常运行呀)
(2)尝试过用#include<system>来代替include<sys/types.h>,include<sys/stat.h>,结果程序运行出错,其实include<system>是包含system函数库的,那么sys又代表什么意思呢?(也就是说sys不是包含system函数库的吗)
(3)如果我想查找相关的头文件包含了哪些函数的话,比如include<sys/stat.h>,在linux下能不能查到呢?或者能怎么做呢?
谢谢
作者: gdutqiang 发布时间: 2011-03-06
#include <sys/types.h>
这个是包括一些基本类型的定义。比如pid_t,ssize_t,size_t之类的。
sys就是和系统相关的包含文件。
那个可以在/usr/incluce目录中找那些包含文件。
这个是包括一些基本类型的定义。比如pid_t,ssize_t,size_t之类的。
sys就是和系统相关的包含文件。
那个可以在/usr/incluce目录中找那些包含文件。
作者: linwhwylb 发布时间: 2011-03-06
初学者,学习中。。。。。。。。
作者: kuilong2010 发布时间: 2011-03-06