如何将两个大文件合并?
我指的是不生成新的文件,而直接让它们合并。当然字节数是簇大小的倍数,能做到吗? 问题点数:60、回复次数:2Top
1 楼phiger(phiger)回复于 2002-12-02 18:55:32 得分 30
CreateFileMapping and MapViewOfFile, write filemapping directly!!Top
2 楼qing_li73(Vincent Lee)回复于 2002-12-02 18:56:02 得分 30
Just use a buffer, transfer the data between the two files
The follow sample showes u copy data from a buffer, u can adjust it for ur requirement
Example
/* WRITE.C: This program opens a file for output
* and uses _write to write some bytes to the file.
*/
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
char buffer[] = "This is a test of '_write' function";
void main( void )
{
int fh;
unsigned byteswritten;
if( (fh = _open( "write.o", _O_RDWR | _O_CREAT,
_S_IREAD | _S_IWRITE )) != -1 )
{
if(( byteswritten = _write( fh, buffer, sizeof( buffer ))) == -1 )
perror( "Write failed" );
else
printf( "Wrote %u bytes to file\n", byteswritten );
_close( fh );
}
}
Output
Wrote 36 bytes to file
Top




