源码如下:
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
void main()
{
int fd;
char s[]="this is linux file!";
fd=open("filew.txt",O_WRONLY|O_CREAT|O_EXCL);
write(fd,s,sizeof(s));
close(fd);
}
用gcc编译到时候提示错误:
file.c: In function ‘main’:
file.c:9: error: ‘O_WRONLY’ undeclared (first use in this function)
file.c:9: error: (Each undeclared identifier is reported only once
file.c:9: error: for each function it appears in.)
file.c:9: error: ‘O_CREAT’ undeclared (first use in this function)
file.c:9: error: ‘O_EXCL’ undeclared (first use in this function)
这是怎么回事啊?
初学者编程到简单问题,关于open函数到错误!
-
- 帖子: 1
- 注册时间: 2012-04-05 15:19
- b33e
- 帖子: 3874
- 注册时间: 2011-06-07 14:20