#include <stdio.h>
void main()
{
//打开文件
FILE *pFile = fopen( "D:\\1.log", "r");
if ( pFile == 0)
{
return;
}
//得到文件的长度
fseek( pFile, 0, SEEK_END);
int iFileLen = ftell( pFile );
fseek( pFile, 0, SEEK_SET);
//得到要的内容
int iLoop = iFileLen / 6 + 1;
char *pResult = new char[iLoop];
for ( int i = 0; i < iLoop; i++)
{
fseek(pFile, i * 6, SEEK_CUR);
pResult[i] = fgetc( pFile );
fseek( pFile, 0, SEEK_SET);
}
fclose( pFile );
//得到的内容放到文件中
pFile = fopen( "D:\\2.log", "w");
if ( pFile == 0)
{
return;
}
fwrite( pResult, 1, iLoop, pFile);
fclose(pFile);
delete pResult;
pResult = 0;
}