Define a structure of containing the following fields
struct word_record
{
char* word;
unsigned int file1_count;
unsigned int file2_count;
};
Then declare an array of struct word_record called word_freq_arr. The size of the array is 2048.
Download the files from the resources folder
File1.txt -> Store it on your desktop as Word1.dat
File2.txt -> Store it on your desktop as Word2.dat
You are to then write a program that will
1. Read Word1.dat word by word, converting the word to lowercase characters. If the word does not exist not exist in word_freq_arr then you will allocate enough memory to store the word and assign the corresponding pointer to word_record.word.
If the word already exists in word_freq_arr then you wil increment the corresponding file1_count.
2. Read Word2.dat word by word,converting the word to lowercase. If the word does not exist not exist in word_freq_arr then you will allocate enough memory to store the word and assign the corresponding pointer to word_record.word. In this case, the field file1_count would be zero because we did not see the word while reading Word1.dat
If the word already exists in word_freq_arr then you wil increment the corresponding file2_count.
3. Sort the word_freq_arr according to the words and write the array to a file called word_freq_cnt.dat in a formatted manner to your desktop.
For example:
If Word1.dat contains the following words
APPLES Oranges Grapes
And Word2.dat contains the following words
apples Grapevine
word_freq_cnt.dat file should look like
Word File1 Count File2 Count Total Count
apples 1 1 2
oranges 1 0 1
grapes 1 0 1
grapevine
struct word_record
{
char* word;
unsigned int file1_count;
unsigned int file2_count;
};
Then declare an array of struct word_record called word_freq_arr. The size of the array is 2048.
Download the files from the resources folder
File1.txt -> Store it on your desktop as Word1.dat
File2.txt -> Store it on your desktop as Word2.dat
You are to then write a program that will
1. Read Word1.dat word by word, converting the word to lowercase characters. If the word does not exist not exist in word_freq_arr then you will allocate enough memory to store the word and assign the corresponding pointer to word_record.word.
If the word already exists in word_freq_arr then you wil increment the corresponding file1_count.
2. Read Word2.dat word by word,converting the word to lowercase. If the word does not exist not exist in word_freq_arr then you will allocate enough memory to store the word and assign the corresponding pointer to word_record.word. In this case, the field file1_count would be zero because we did not see the word while reading Word1.dat
If the word already exists in word_freq_arr then you wil increment the corresponding file2_count.
3. Sort the word_freq_arr according to the words and write the array to a file called word_freq_cnt.dat in a formatted manner to your desktop.
For example:
If Word1.dat contains the following words
APPLES Oranges Grapes
And Word2.dat contains the following words
apples Grapevine
word_freq_cnt.dat file should look like
Word File1 Count File2 Count Total Count
apples 1 1 2
oranges 1 0 1
grapes 1 0 1
grapevine