#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>

int main(void)
{
	char buf[1024];

	int ret = 0;

	int fd = open("./dict.txt",O_RDWR);
	printf("fd=%d\n",fd);
	printf("errno=%d\n",errno);
	while((ret = read(fd, buf, sizeof(buf))))
	{
		write(STDOUT_FILENO,buf,ret);
	}
	close(fd);
	printf("close ok...\n");
	return 0;
}

 

Logo

更多推荐