Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Unable to get the following code to execute properly. I have documents named keyword.txt and resume.txt saved to my computer but unclear what else is

Unable to get the following code to execute properly. I have documents named keyword.txt and resume.txt saved to my computer but unclear what else is required for the program to run as it should. This is the assignment...

  • Demonstrate the ability to manipulate strings
  • Demonstrate the use of IO files

Most larger companies have software programs that scan through submitted resumes and select the best resumes as possible interview clients.

Your program will assume that there is a text file representing an applicants resume as a text file. The resume text document needs to be placed in the SRC folder of the project. You will create a sample resume as a text file to use for this purpose.

You will create another separate text file which will also be placed in the SRC folder. This file will contain a group of keywords separated by commas. No keyword will contain a comma. You are to count the total times the keywords are found in the fake resume.

Your program must simply output to the screen the count of keywords within the document that match the keywords.

In real life the higher the number the higher the chance that the person (who created the resume) will get an interview.

Your cannot use global variables or goto statements.

#include #include #include

/*Assuming keyword file keyword.txt and resume file resume.txt */

int main() {

FILE *fp, *fp1; int i;

char line[100]; char words[100][50];

fp = fopen_s("keyword.txt", "r"); if (fp == NULL) { printf("Error opening file "); return 0; } int count = 0; while (fgets(line, 100, fp) != NULL) { char *ch = strtok_s(line, ","); while (ch != NULL) { strcpy_s(words[count], ch); count++; ch = strtok_s(NULL, ","); } } fclose(fp); fp = fopen_s("resume.txt", "r"); if (fp == NULL) { printf("Error opening file "); return 0; } int count1 = 0; while (fgets(line, 100, fp) != NULL) { char *ch = strtok_s(line, " "); while (ch != NULL) { for (i = 0; i < count; i++) { if (strcmp(ch, words[i]) == 0) { count1++; } } ch = strtok_s(NULL, ","); } } fclose(fp); printf("Total count of keywords is %d ", count1);

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What magazine and ads did you choose to examine?

Answered: 1 week ago