一,文件差分
再時還是有一點問題就是差分的時候中視頻不好看這個問題我將在以後更新
/*************************************************************************
> File Name:文件差分
> Author: songli
> QQ:2734030745
> Mail: 15850774503@163.com
> Created Time:
************************************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
FILE *in = fopen("/home/chenli/FILE/chenli.avi", "rb");
if (!in)
{
printf("can not open file \n");
system("pause");
return -1;
}
struct stat st;
stat("/home/chenli/FILE/chenli.avi", &st);
long file_length = st.st_size;
printf("file length%d\n", file_length);
char *buf = (char *)malloc(sizeof(char) * 1024 * 1024 * 10);
char ch[29] = "/home/chenli/FILE/chen";
char i = 'a';
while (!feof(in))
{
ch[22] = '_';
ch[23] = i;
ch[24] = '.';
ch[25] = 'a';
ch[26] = 'v';
ch[27] = 'i';
ch[28] = '\0';
FILE *out = fopen(ch, "wb");
memset(buf, 0, sizeof(char) * 1024 * 1024 * 10);
int len= fread(buf, sizeof(char), 1024 * 1024 * 10, in);
fwrite(buf, sizeof(char), len, out);
i++;
fclose(out);
}
free(buf);
buf == NULL;
fclose(in);
system("pause");
return EXIT_SUCCESS;
}
二,和並
和並這裏沒有問題
/*************************************************************************
> File Name: 和並
> Author: songli
> QQ:2734030745
> Mail: 15850774503@163.com
> Created Time:
************************************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
int main(int argc, char *argv[])
{
FILE *file = fopen("/home/chenli/FILE/file.avi", "a+b");
if (!file)
{
printf("file can not !");
return -1;
}
char *buf = (char *)malloc(sizeof(char *) * 1024 * 1024 * 100);
char ch[28] = "/home/chenli/FILE/chen";
char i = 'a';
while ( i == 'a' || i == 'b' || i == 'c' || i == 'd')
{
ch[22] = '_';
ch[23] = i;
ch[24] = '.';
ch[25] = 'a';
ch[26] = 'v';
ch[27] = 'i';
ch[28] = '\0';
FILE *out = fopen(ch, "rb");
if (!out)
return - 1;
memset(buf, 0, sizeof(char *) * 1024 * 1024 * 100);
long length = fread(buf, sizeof(char *), 1024 * 1024 * 100, out);
int chen = fseek(file, 0, SEEK_END); //定位的文件的末尾
printf("chen = %d\n", chen);
long len = ftell(file); //获取到当前文件的位置 查看文件的当前位置的信息
printf("len = %d\n", len);
fwrite(buf, sizeof(char *), length, file);
fclose(out);
i++;
}
free(buf);
fclose(file);
/*_kbhit();
char ch;
ch = _getch();
printf("%c", ch);*/
system("pause");
return EXIT_SUCCESS;
}