首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

O_RDONLY’ undeclared 异常

2012-05-12 
O_RDONLY’ undeclared 错误求助大家好!我在ununtu系统下用gcc编译自已写的小程序出现如题的错误,求指教是

O_RDONLY’ undeclared 错误求助
大家好!我在ununtu系统下用gcc编译自已写的小程序出现如题的错误,求指教是否要包含什么头文件,然后gcc的命令要怎么写?

我编译时的命令是 gcc -o 8_1 8_1.c -lm

×××××××××××××源文件如下×××××××××××××××××

C/C++ code
#include <stdio.h>#include <sys/types.h>#include <unistd.h>void filecopy(int fd1,int fd2);int main(int argc, char *argv[]){    int fd1,fd2;    if (3 != argc)        return -1;    if ((fd1 = open(argv+1,O_RDONLY,0)) == -1)        return -2;    if ((fd2 = open(argv+2,O_RDONLY,0)) == -1)        return -2;    filecopy(fd1,fd2);}void filecopy(int fd1,int fd2){    int n;    char *str[100];    while ((n = read(fd1,str,100)) !=-1 && n != 0 )        write(1,str,n);    while ((n = read(fd2,str,100)) != -1 && n != 0)        write(1,str,n);}


[解决办法]
man 2 open
将出现的头文件都包含进去。

热点排行