我有这个从infile到outfile的复制代码,问题是在outfile的末尾添加了很多垃圾
ssize_t nread;
int bufsize=512;
char buffer[bufsize];
while ( (nread=read(infile, buffer, bufsize)>0))
{
if( write(outfile, buffer, bufsize)<nread )
{
close(outfile); close(infile); printf("error in write loop !\n\n");
return (-4);
}
}
if( nread == -1) {
printf ("error on last read\n"); return (-5);
}//error on last read /
我该怎么做才能解决这个问题?