标签:
#include <fcntl.h>
#include <stdio.h>
int main(void){
int fd;
char w[100];
char r[100];
fd = open("./a.txt", O_RDWR|O_EXCL, S_IRUSR|S_IWUSR|S_IXUSR);
int r1 = read(fd,r,10);
printf("%d",fd);
printf("%s",r);
return 0;
}
以上代表把a.txt中的前十个字符读进r数组。#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
int main(void){
int fd;
char w[100];
char r[100];
fd = open("./a.txt", O_RDWR|O_EXCL, S_IRUSR|S_IWUSR|S_IXUSR);
int r1 = read(fd,r,10);
write(STDOUT_FILENO,r,10);
//printf("%d",fd);
//printf("%s",r);
return 0;
}
以上代码上将从a.txt中读进来的内容,写入标准输出,也就是控制台上。标签:
原文地址:http://blog.csdn.net/a879365197/article/details/46594213