LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 3528|回复: 3

大家来看看这个程序,不知少了什么头文件?

[复制链接]
发表于 2002-11-18 16:20:34 | 显示全部楼层 |阅读模式
文件 write.c

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char boot_buf[512];
    int floppy_desc,file_desc;
    file_desc = open("./boot",O_RDONLY);
    read(file_desc,boot_buf,510);
    close(file_desc);
    boot_buf[510] = 0x55;
    boot_buf[511] = 0xaa;
    floppy_desc = open("/dev/fh0",O_RDWR);
    lseek(floppy_desc,0,SEEK_CUR);
    write(floppy_desc,boot_buf,512);
    close(floppy_desc);
}

用 cc write.c -o write 命令后显示如下

write.c: In function `main':
write.c:9: `O_RDONLY' undeclared (first use in this function)
write.c:9: (Each undeclared identifier is reported only once
write.c:9: for each function it appears in.)
write.c:14: `O_RDWR' undeclared (first use in this function)
write.c:18:2: warning: no newline at end of file

不知怎么解决?
发表于 2002-11-18 18:17:47 | 显示全部楼层
$ man 2 open
 楼主| 发表于 2002-11-18 18:33:36 | 显示全部楼层
能不能详细的吗?
发表于 2002-11-18 23:28:53 | 显示全部楼层
加上这几个头文件fcntl.h,sys/types.h,sys/stat.h。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表