发信人: kingfox()
整理人: yangcs(2000-01-21 14:30:52), 站内信件
|
# include <stdio.h>
# include <string.h>
char LstFile[256];
char FragFile[64];
char DestFile[256];
int main()
{
FILE *fpLst, *fpDest, *fpFrag;
char Buf;
do {
printf( "Fragment list file: " );
scanf( "%s", LstFile );
fpLst = fopen( LstFile, "r" );
if ( fpLst == NULL )
printf( "Error: can't open list file -- %s\n", fpLst );
} while( fpLst == 0 );
fscanf( fpLst, "%s", DestFile );
fpDest = fopen( DestFile, "wb" );
if ( fpDest == NULL )
{
printf( "Error: can't create destination file -- %s\n", DestFile );
fclose( fpLst );
return 1;
}
printf( "Creating destination file %s ...", DestFile );
do {
fscanf( fpLst, "%s", FragFile );
if ( feof( fpLst ) )
break;
fpFrag = fopen( FragFile, "rb" );
if ( fpFrag == NULL )
{
printf( "Error: can't open frag-file -- %s\n", FragFile );
fclose( fpDest );
fclose( fpLst );
return 2;
}
printf( "\nReading source %s ...", FragFile );
while( !feof(fpFrag) )
{
fread( &Buf, 1, 1, fpFrag );
if ( feof( fpFrag ) )
{
fclose( fpFrag );
break;
}
fwrite( &Buf, 1, 1, fpDest );
}
} while( !feof( fpLst ) );
printf( "\nSuccess! Destination file is: %s\n", DestFile );
fclose( fpDest );
fclose( fpLst );
return 0;
}
-- ------------------------------------------------------------
有缘则聚,缘尽则散,随缘而定,随遇而安。
------------------------------------------------------------
欢迎光临“电子工程师园地”http://kingfox.163.net
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.101.0.37]
|
|