免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 12416 | 回复: 2
打印 上一主题 下一主题

急问:fcnt1.h:No such file or directory是什么意思? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-08-02 21:10 |只看该作者 |倒序浏览
Redhat linux环境下的C语言程序,普通用户登陆,没有开发板,用vi来编写程序并调试、运行。
把书上的程序完全输进去之后,再编译。
显示如下的错误信息:
open.c:5:18: fcnt1.h:No such file or directory
open.c: In function 'main':
open.c:11: error: 'O_CREAT' undeclared(first use in this function)
open.c:11: error: (Each undeclared identifier is reported only once
open.c:11: error: for each function it appears in.)
open.c:11: error: 'O_TRUNC' undeclared(first use in this function)
open.c:11: error: 'O_WRONLY' undeclared(first use in this function)

完整的源代码如下(是书上的):
/*open.c*/
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcnt1.h>
#include<stdlib.h>
#include<stdio.h>
int main(void)
{
int fd;
if((fd=open("/tmp/hello.c",O_CREAT|OTRUNC|O_WRONLY,0600))<0)
{
perror("open:");
exit(1);
}
else
{
printf("Open file:hello.c %d\n",fd);
}
if(close(fd)<0)
{
perror("close:");
exit(1);
}
else
printf("Close hello.c\n");
exit(0);
}

注:那个“fcnt1.h”的“1”,是阿拉伯数字,而不是小写的“L”。

请问:到底哪里出了问题?该怎么改?请详细解答。
谢谢。

论坛徽章:
0
2 [报告]
发表于 2010-08-02 21:24 |只看该作者
个人认为,你看的书上由于印刷错误,把fcntl.h 打印成了fcnt1.h

论坛徽章:
59
2015七夕节徽章
日期:2015-08-24 11:17:25ChinaUnix专家徽章
日期:2015-07-20 09:19:30每周论坛发贴之星
日期:2015-07-20 09:19:42ChinaUnix元老
日期:2015-07-20 11:04:38荣誉版主
日期:2015-07-20 11:05:19巳蛇
日期:2015-07-20 11:05:26CU十二周年纪念徽章
日期:2015-07-20 11:05:27IT运维版块每日发帖之星
日期:2015-07-20 11:05:34操作系统版块每日发帖之星
日期:2015-07-20 11:05:36程序设计版块每日发帖之星
日期:2015-07-20 11:05:40数据库技术版块每日发帖之星
日期:2015-07-20 11:05:432015年辞旧岁徽章
日期:2015-07-20 11:05:44
3 [报告]
发表于 2010-08-03 12:44 |只看该作者
没有目录或者文件,头文件不存在。可能是错了。

论坛徽章:
0
4 [报告]
发表于 2019-03-29 07:56 |只看该作者
fcntl中非阿拉伯数字“1”,而是字母“L”的小写。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP