#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<errno.h>
#define BUFFER_SIZE 1024
int main()
{
int aim_fd;
int i;
int bytes_write,bytes_read;
// char buffer[BUFFER_SIZE];
char str[]="hello";
char *ptr;/*,*stp=str*/
ptr=str;
if(aim_fd=(open("hello.txt",O_WRONLY|O_CREAT,0644))==-1)
{
perror("open error!");
exit(-1);
}
for(i=0;i<3;i++)
{
while(bytes_write=write(aim_fd,ptr,5))
{
if((bytes_write==-1)&&(errno!=EINTR))
break;
else if(bytes_write>0)
{
ptr+=bytes_write;
}
}
}
/* while(bytes_read==read(aim_fd,buffer,BUFFER_SIZE))
{
if((bytes_read==-1)&&(errno!=EINTR))
break;
else if(bytes_read>0)
{
}
}
printf("%s",buffer);*/
close(aim_fd);
}
#include<stdlib.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<errno.h>
#define BUFFER_SIZE 1024
int main()
{
int aim_fd;
int i;
int bytes_write,bytes_read;
// char buffer[BUFFER_SIZE];
char str[]="hello";
char *ptr;/*,*stp=str*/
ptr=str;
if(aim_fd=(open("hello.txt",O_WRONLY|O_CREAT,0644))==-1)
{
perror("open error!");
exit(-1);
}
for(i=0;i<3;i++)
{
while(bytes_write=write(aim_fd,ptr,5))
{
if((bytes_write==-1)&&(errno!=EINTR))
break;
else if(bytes_write>0)
{
ptr+=bytes_write;
}
}
}
/* while(bytes_read==read(aim_fd,buffer,BUFFER_SIZE))
{
if((bytes_read==-1)&&(errno!=EINTR))
break;
else if(bytes_read>0)
{
}
}
printf("%s",buffer);*/
close(aim_fd);
}
1278

被折叠的 条评论
为什么被折叠?



