Question: Hello! Just need more help with this I/O assignment. I will provide the solution I have below. Please build based off this. Issues I am
Hello! Just need more help with this I/O assignment. I will provide the solution I have below. Please build based off this.
Issues I am still having:
---The rating at the end is not quite correct. For the end score, I need to calculate the amount of times that a keyword appears in the resume document by scanning and comparing to the keyword file document. All I have to do is keep track of how many times a keyword was counted in the resume document. I tried to just use a keyword_tracker variable, but however this still wont work. (if it 5 keywords appear then rating would just be 5 --- don't need to add percent)
---I need all the keyword stuff & and the calculations to be in their own individual function below main and just called into the main function. (What would I pass in these????)
I keep positing this question because the cirteria is a little ambigous and I am trying to understand it and the whole concept. All help is appreciated ! Thank you !!!!!!
Solution:
*Please pretend these files exist*
#include
int main() { FILE *keywordFile; char keywords[1000][1000];
keywordFile = fopen("keywordFile.txt", "r"); if (keywordFile == NULL) { printf("Unfortuntely, we encountered an issue when trying to access your file. Please contact tech support to solve your issue. The program will be exiting briefly"); exit(-1); } int line = 0; while (!feof(keywordFile) && !ferror(keywordFile)) { if (fgets(keywords[line], 100, keywordFile) != NULL) { keywords[line][strlen(keywords[line])-1] = '\0'; line++; } } fclose(keywordFile); FILE *fakeResume; char res[1000][1000]; //opening the file fakeResume = fopen("fakeResume.txt", "r"); if (fakeResume == NULL) { printf("Unfortuntely, we encountered an issue when trying to access your file. Please contact tech support to solve your issue. The program will be exiting briefly"); exit(-1); } int line2 = 0; while (!feof(fakeResume) && !ferror(fakeResume)) { if (fgets(res[line2], 100, fakeResume) != NULL) { res[line2][strlen(res[line2])-1] = '\0'; line2++; } } //closing the file fclose(fakeResume);
int keyword_tracker = 0; for (int i = 0; i < line2; i++) { for (int j = 0; j < line; j++) { if (strstr(res[i], keywords[j]) != NULL) { keyword_tracker++; } } }
printf("Your Resume Rating: %d ", keyword_tracker);
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
