标签:style blog io ar color os sp on div
#include<unistd.h> #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<stdio.h> int main() { int fd,size; char s []="Linux Programmer!\n",buffer[80]; fd=open("/root/Documents/kkkkk/leijiangtao/myfile",O_WRONLY|O_CREAT); write(fd,s,sizeof(s)); close(fd); fd=open("/root/Documents/kkkkk/leijiangtao/myfile",O_RDONLY); size=read(fd,buffer,sizeof(buffer)); printf("%s",buffer); close(fd); return 0; } //"/root/Documents/leijiangtao/myfile"这句一定要写完整尤其是root前面的那个/ //myfile后面加不加后缀无所谓 //再就是要注意汉子的符号 /* [root@linux 已利用]# gcc open.c [root@linux 已利用]# ./a.out Linux Programmer! [root@linux 已利用]# */
标签:style blog io ar color os sp on div
原文地址:http://www.cnblogs.com/leijiangtao/p/4110887.html