C/C++バイナリ追加読み書きファイル


#include <stdio.h> //           ,printf scanf     
#include <stdlib.h>  //      ,    、          

//         ,  fopen     "b"   
#define MAXLEN 1024
int main()
{
	int rc;
	FILE * outfile, *infile;
	int i = 0;
	for(i =0; i<=45; i++) {
		char fileopen[15] = {0};
		sprintf(fileopen,"222.rmvb_%d.!mv",i);
		outfile = fopen("222.rmvb", "ab" );//  
		infile = fopen(fileopen, "rb");
		unsigned char buf[MAXLEN];
		if( outfile == NULL || infile == NULL ) {
			exit(1);
		}

		while( (rc = fread(buf,sizeof(unsigned char),MAXLEN,infile)) != 0 ) {
			fwrite( buf, sizeof( unsigned char ), rc, outfile );
		}
		fclose(infile);
		fclose(outfile);

	}

	return 0;
}