#include #include "count.h" #include #include void specialcount(char *path, char *fileto

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

#include #include "count.h" #include #include void specialcount(char *path, char *fileto

Post by answerhappygod »

#include <stdio.h>
#include "count.h"
#include <dirent.h>
#include <string.h>
void specialcount(char *path, char *filetowrite, longcharfreq[])
{
/**
The specialcharcount function counts the frequency of thefollowing 5 special words:
"he" "she" "they" "him" "me"
in all the .txt files under directory of the given path andwrite the results to a file named as filetowrite.
Input:
path - a pointer to a char string [a character array] specifyingthe path of the directory; and
filetowrite - a pointer to a char string [a character array]specifying the file where results should be written in.
charfreq - a pointer to a long array storing the frequency ofthe above 5 special words
charfreq[0]: the frequency of "he"
charfreq[1]: the frequency of "she"
charfreq[2]: the frequency of "they"
charfreq[3]: the frequency of "him"
charfreq[4]: the frequency of "me"
Output: a new file named as filetowrite with the frequency ofthe above 5 special words written in
Steps recommended to finish the function:
1) Find all the files ending with .txt and store infilelist.
2) Read all files in the filelist one by one and count thefrequency of each of the above special words. The array
long charfreq[] always has the up-to-date frequencies of specialwords counted so far. If the word is upper case, convert
it to lower case first.
3) Write the result in the output file: filetowrite in followingformat:
character -> frequency
example:
he -> 20
she -> 11
they -> 20
him -> 11
me -> 12
Assumption:
1) You can assume there is no sub-directory under the given pathso you don't have to search the files
recursively.
2) Only .txt files are counted and other types of files shouldbe ignored.
*/
WRITE IN C PLEASE I WILL THUMBS DOWN IF THE ANSWER ISCOPY PASTED
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply