下面是一个c语言读写二进制文件的一个例子
void read_write_file(){ const int MAXLEN =1024; FILE * outfile, *infile; outfile = fopen("F:\\training video\\_back\\2.wmv", "wb" ); infile = fopen("F:\\training video\\_back\\1.wmv", "rb"); unsigned char buf[MAXLEN]; if( outfile == NULL || infile == NULL ) { // printf(%s, %s,argv[1],not exit\n); exit(1); } int rc; while( (rc = fread(buf,sizeof(unsigned char), MAXLEN,infile)) != 0 ) { fwrite( buf, sizeof( unsigned char ), rc, outfile ); } fclose(infile); fclose(outfile); cout<<"read,write success"<<endl; }