文件的逆序存储
 

HTML Tags and JavaScript tutorial



文件的逆序存储





#include "stdio.h"
#include "io.h"
#include "fcntl.h "
void Flip()
{
 char Buffer[1024],Temp;
 int i;
 int  nReadLength,nRead;
 int nLoop,nArrLen;
 long nFileLength,SeekOffSet;
 int handle;
 FILE * SourceFile,*TargetFile;
 
 handle = open("00",O_RDONLY);
 nFileLength = filelength(handle);
 
 SourceFile = fopen("00","rb");
 TargetFile = fopen("11","wb");
 
 nReadLength = 1;
 SeekOffSet = nFileLength - 1024;
 nRead = 1024;
 nLoop = 512;
 nArrLen = 1023;
 while(nReadLength != 0)
 {
  fseek(SourceFile,SeekOffSet,SEEK_SET);
  nReadLength = fread(Buffer,sizeof(char),nRead,SourceFile);
  for(i=0;i<nLoop;i++)
  {
   Temp = Buffer[i];
   Buffer[i] = Buffer[nArrLen-i];
   Buffer[nArrLen-i] = Temp;
  }
  fwrite(Buffer,sizeof(char),nReadLength,TargetFile);
  if(SeekOffSet < 1024)
  {
   nRead = SeekOffSet;
   SeekOffSet = 0;
   nLoop = nRead/2;
   nArrLen = nRead -1;
  }
  else
   SeekOffSet -= 1024;
  if( nReadLength < 1024 )
   nReadLength = 0;
 }
 fclose(SourceFile);
 fclose(TargetFile);
}
main()
{
 Flip();

本程序在TC2.0下调试通过,源文件文件名是“00”,生成的文件名是“11”。


阅读更多
上一篇从PEB中取出MODULENAME
下一篇两个webconfig
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

文件的逆序存储

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭