O_RDONLY’ undeclared 错误求助
大家好!我在ununtu系统下用gcc编译自已写的小程序出现如题的错误,求指教是否要包含什么头文件,然后gcc的命令要怎么写?
我编译时的命令是 gcc -o 8_1 8_1.c -lm
×××××××××××××源文件如下×××××××××××××××××
#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);}