// Just for test
#include
#include
#include
#include
int main(void)
{
int fd = -1,ret = -1;
char strings[] = "Hello World!";
char buf[] = {0};
fd = open("b.c",O_RDWR | O_CREAT | O_EXCL,0666);
if ( !fd ) {
printf("Open file error! \n");
} else {
//printf("fd = %d \n",fd);
perror("b.c");
}
ret = write(fd,strings,strlen(strings));
if( -1 == ret ) {
printf("ret = %d\n",ret );
perror("strings");
} else {
perror("strings");
printf("ret = %d\n",ret );
}
close(fd);
fd = open("b.c",O_RDONLY);
ret = read(fd,buf,strlen(strings) );
printf("buf = %s\n",buf);
close(fd);
return 0;
}
阅读(1205) | 评论(0) | 转发(0) |