|
发表于 2004-3-29 12:39:57
|
显示全部楼层
这个程序在UNIX下就可以编译并正常运行,在LINUX就不可以编译通过,在LINUX怎么些呢?
- #include <stdio.h>
- #include <unistd.h>
- #include <fcntl.h>
- int
- main(void)
- {
- int fd,n;
- char buf[10];
- if((fd=open("/etc/fstab",O_RDONLY))<0) {
- printf("open file error\n");
- return(1);
- }
- for(n=0;n<10;n++) {
- if(read(fd,&buf[n],1) != 1 ) {
- printf("read error\n");
- return(1);
- }
- if(write(STDOUT_FILENO,&buf[n],1) == NULL ) {
- printf("write error\n");
- return(1);
- }
- }
- return(0);
- }
- # gcc -c get_1_byte.d.c
- get_1_byte.d.c: In function `main':
- get_1_byte.d.c:18: warning: comparison between pointer and integer
复制代码
:help |
|