Write a resume scanning simulator. You are to write a program that will read in
ID: 3873692 • Letter: W
Question
Write a resume scanning simulator. You are to write a program that will read in a resume (you can assume that the document is located with the source file and it is named resume.txt (make this up). Your program will read in a text file that contains KEYWORDS from zero to 50 keywords (make this up). For example: "programming", "C", "Java", "object", "motivated", "skilled", "......." This text file of words will contain a words 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 will simply output to the screen the count of keywords with in the document. In real life the higher the number the higher the chance that the person (the owner of the resume) will get an interview. In C language You are to turn in your design tool, your input file, your sample resume.txt, and your source file.
Explanation / Answer
First create a C proram named ResumeScanner. In that file create const char pointer array of 50 keywords like this
const char *keywords[50];
keywords[0] = "programming";
keywords[1] = "C";
upto
keywords[49] = "Java";
or you can directly create array like
const char *keywords[50] = {"programming","C",..,"Java"};
here we are creating const array becaue we are not going to change this value during the life time of the program
now create another int array that will store the occurances of each character and assign default value 0. Because it does not have any defaul value so its a good to assign a default value at the time of declaration.
int occ[50]={0}; //So each int has now 0 value default.
int iter=0,result=0;
now open a file "resume.txt" in read mode
FILE *fp = fopen("resume.txt","r"); // opens a file in read mode
char buf[40]; // buffer of 40 char (for single word)
while( fscanf(fp, "%s", buf) != EOF ) // fetches a word form file and store it in buf
{
for(iter =0 ;iter<50;iter++) // searches for the keyword
{
result=strcmp(buf,keywords[iter]); // strcmp function will compare two strings. If both are equal then returns 0.
if(result==0)
{
occ[iter]=occ[iter]++; // keyword at position iter is matches so increase the occurancy by 1
break; // break the for loop and get another word from file
}
}
}
flose(fp); // closes the file
Now print the keywords and its occurences through for loop
for(iter =0;iter<50;iter++)
{
printf(" %s - %d ",keywords[iter],occ[iter]);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.