初学unix环境编程 求助
自己写了一个简单函数 就是创建文件 然后向文件写数据
但是数据被打印到了终端 不能写到文件里 求帮助
#include "apue.h"
#include <fcntl.h>
char buf1[] = "congratulation";
int
main (void){
int fd,bytes;
off_t offset;
if(fd = open("myfile.txt", O_RDWR|O_EXCL|O_CREAT, FILE_MODE) == -1)
printf("creat/open fail\n");
else
printf("myfile.txt fd = %d\n",fd);
if(offset = lseek(fd, 0, SEEK_CUR) == -1)
printf("cannot lseek\n");
else
printf("lseek file with nothing ,lseek = %d\n",offset);
if(bytes = write(fd, buf1, 14) == -1)
printf("write fail\n");
else
printf("write bytes = %d\n",bytes);
exit(0);
}