41 lines
702 B
C++
41 lines
702 B
C++
// mergeTwoFiles.cpp : Defines the entry point for the console application.
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
int _tmain(int argc, _TCHAR* argv[])
|
|
{
|
|
FILE* f1 = fopen( "D:\\tmp\\pf.avi", "rb" );
|
|
FILE* f2 = fopen( "D:\\tmp\\PulpFiction2.avi", "rb" );
|
|
FILE* o = fopen( "D:\\tmp\\aaaa.avi", "wb" );
|
|
|
|
char buf[2048];
|
|
for ( ; !feof( f1 ); )
|
|
{
|
|
int n = fread( buf, 1, sizeof( buf ), f1 );
|
|
if ( !n )
|
|
break;
|
|
|
|
bool b = false;
|
|
for ( int i = 0; !b && i < n; ++i )
|
|
if ( buf[i] )
|
|
b = true;
|
|
|
|
if ( !b )
|
|
{
|
|
int pos = ftell( f1 );
|
|
fseek( f2, pos, SEEK_SET );
|
|
n = fread( buf, 1, sizeof( buf ), f2 );
|
|
}
|
|
|
|
fwrite( buf, 1, n, o );
|
|
}
|
|
|
|
fclose( o );
|
|
fclose( f1 );
|
|
fclose( f2 );
|
|
return 0;
|
|
}
|
|
|