Every year XYZ holdings needs a consolidated list with
all of the people employed at all of their
branches. XYZ holdings received the two files below:
Gauteng Branch (Gauteng.dat)
Gauteng Employee Name Gauteng Employee Surname
Chris Hanson
Evelyn Harrison
Helen Cooper
Martin Anderson
KZN Branch (KZN.dat)
KZN Employee Name KZN Employee Surname
Allice Johnson
Evan Christopherson
Q.3.1 Write the pseudocode that will merge the two files into one
consolidated file
called “BranchConsolidation.dat”.
[
Writing the Pseudo code using 'C' Program
#include <stdio.h>
int main()
{
FILE *fa1, *fa2, *fo;
char ch, file1[30], file2[30], file3[30];
printf("Name of the File1\n");
gets(file1);
printf("Name of the File2\n");
gets(file2);
printf("Consolidated List file\n");
gets(file3);
fa1 = fopen(file1, "r");
fa2 = fopen(file2, "r");
if (fa1 == NULL || fa2 == NULL)
{
printf("Press any key to exit...\n");
exit();
}
fo = fopen(file3, "w");
if (fo == NULL)
{
printf("Press any key to exit...\n");
exit();
}
while( (ch = fgetc(fa1)) != EOF)
fputc(ch, fo);
while( (ch = fgetc(fa2)) != EOF)
fputc(ch, fo);
printf("The 2 files are merged together \n", file3);
fclose(fa1);
fclose(fa2);
fclose(fo);
}
Get Answers For Free
Most questions answered within 1 hours.