int main()
{
int fd = open("BTree.c", O_RDONLY, 0777);
if (fd == -1)
{
perror ("open");
return -1;
}
char buf[SIZE] = {0};
char *p = buf;
int count = SIZE-1; // 每一次要读的数据个数
ssize_t ret = 0;
while (ret = read(fd, p, count))
{
// 出错
if (ret == -1)
{
if (errno == EAGAIN || errno == EINTR)
{
continue;
}
break;
}
printf ("asdasdsadsa\n");
// 读完
if (count == ret)
{
break;
}
count -= ret; // 下一次要读的数据
p += ret;
}
printf ("len = %d\n", strlen(buf));
//printf ("%s\n", buf);
return 0;
}