#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _CRT_SECURE_NO_WARNINGS
void splitTextFile(const char* file_path, int max_embed, int first_slice_length, int second_slice_length) {
FILE* input_file = fopen(file_path, "r");
if (input_file == NULL) {
printf("Error: Cannot open input file.\n");
return;
}
fseek(input_file, 0, SEEK_END);
long file_size = ftell(input_file);
rewind(input_file);
FILE* first_slice_file = fopen("first_slice.bin", "w");
FILE* second_slice_file = fopen("second_slice.bin", "w");
if (first_slice_file == NULL || second_slice_file == NULL) {
printf("Error: Cannot create output files.\n");
fclose(input_file);
return;
}
char *buffer = new char[file_size+1];
fread(buffer, 1, file_size, input_file);
fclo
C/C++实现文本文件分片操作
最新推荐文章于 2023-12-17 02:53:00 发布