include <stdio.h>
include <stdlib.h>
void backupFile(const char sourceFile, const char backupFile) {
FILE source, backup;
char buffer[1024];
source = fopen(sourceFile, "r");
if (source == NULL) {
perror("Error opening source file");
return;
}
backup = fopen(backupFile, "w");
if (backup == NULL) {
perror("Error creating backup file");
fclose(source);
return;
}
while (fgets(buffer, sizeof(buffer), source) != NULL) {
fputs(buffer, backup);
}
fclose(source);
fclose(backup);
printf("Backup completed successfully.\n");
}
利唐i人事HR社区,发布者:HR数字化研究员,转转请注明出处:https://www.ihr360.com/hrnews/20241236361.html