这段程序实现了把一个文件拷贝到另一个文件,为什么总写不进文件?谢谢各位!!
#define EVERY_BLOCK_SIZE 1024*100
STATUS writefile(char* fFileram,char* fFiletffs)
{
int fdRam;
FILE* fpTffs;
FILE* fpTemp;
STATUS st=OK;
int number;
char* tempBuffer;
int numBytes,totalBytes;
tempBuffer=malloc(EVERY_BLOCK_SIZE);
fdRam=open(fFileram,O_RDONLY,0);
if(fdRam==ERROR)
{
printf("open file %s error\n",fFileram);
st=ERROR;
/* return(st);*/
}
else
{
printf("open file %s success\n",fFileram);
st=OK;
}
fpTffs=fopen(fFiletffs,"a+");
if(fpTffs==NULL)
{
printf("open filetffs %s error\n",fFiletffs);
st=ERROR;
/*return(st);*/
}
else
{
printf("open filetffs %s success\n",fFiletffs);
st=OK;
}
while((numBytes=read(fdRam,tempBuffer,EVERY_BLOCK_SIZE))>0)
{
printf("tempBuffet =%s \n numBytes=%d \n",tempBuffer,numBytes);
/*if ((number=fwrite (tempBuffer,numBytes,1,fpTffs)) <1)*/
if(fputs(tempBuffer,fpTffs)==EOF)
{
printErr ("copy: error writing file. errno %p\n", (void *) errno);
free (tempBuffer);
st=ERROR;
return (st);
}
else
{
printf("number=%d\n",number);
}
totalBytes += numBytes;
}
return(st);
}