Splitting and merging of files

Source: Internet
Author: User

/* Partition of File/* #include <stdio.h> #include <stdlib.h> #include <string.h> #define &NBSP;NUM&NBSP;1024  * 1024 * 100int main () {        // Required split file path File *fr = fopen ("F:\\pl.exe",  "RB");if  (Fr == null) {exit (-1);} char *buff =  (char*) malloc (sizeof (char)  * num);if  (buff == null) {exit ( -2);} size_t rs = 0; File *fw;// = fopen ("F:\\1.exe",  "WB");//The partitioned file is cycled to the target path char str[100] =  "F : \ \ ";     char tmp_file[100];char name[100];int i = 1;while ((rs   = fread (Buff,sizeof (char), NUM,&NBSP;FR)) ( > 0) {// sprintfitoa (i,name,10);//     i->1-->name--> "1" strcpy (TMP_FILE,&NBSP;STR);// tmp_file ->> "F : \ \ "Strcat (tmp_file,name);//       f:\\1strcat (tmp_file, ". exe "); fw&Nbsp;= fopen (tmp_file,  "WB"); Fwrite (buff,sizeof (char) &NBSP;,RS,&NBSP;FW); fclose (fw); i++;} Fclose (FR); return 0;} /* File Merge */#include <stdio.h> #include <stdlib.h> #include <string.h> #define  num 1024* 1024*100// 10mbint main () {File *fr1 = fopen ("F:\\1.exe",  "RB");  // The segmented file path File *fr2 = fopen ("F:\\2.exe",  "RB"); File *fw = fopen ("F:\\meger.exe",  "WB");//target path after file merge char *buff =  (char*) malloc (sizeof (char)  * num);//size_t rs = 0; file *arr[] = {fr1,fr2};for  (int i=0;i<2;i++) {while (Rs = fread (Buff, sizeof (char), Num, arr[i])) ( > 0) {fwrite (buff, sizeof (char), &NBSP;RS,&NBSP;FW);} Fclose (Arr[i]);} Fclose (FW); free (buff); return 0;}


Splitting and merging of files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.