arrays - searching a .txt. file from another .txt file in c -
i scrutiny question @ point take whatever can get. seek , create i'm having problem simple possible in step step objective.
i'm trying to:
read in .txt file of keywords print them read in .txt resume(the programme resume scanner) search resume keywords output keyword count of ho many times used.
i can output both resume array , keyword array when search , output part breaks. i'm trying see if i'm close search code.
my professor gave assignment while , couldn't figure out search , output part of it. have free time wanted go , seek , figure out no luck. below code have. want apologize length, i'm not trying blast post bunch of code sense relevant. take bad rep on here if can @ to the lowest degree larn this. sense important. give thanks in advance!
#define _crt_secure_no_warnings #include<stdio.h> #include <stdlib.h> #define pause system("pause") #define cls system("cls") #include <string.h> main(){ file* pfile; file* resume; char f[50] = { "" }; char r[50] = { "" }; char search = ""; int = 0, j = 0; int count = 0, c = 0; printf("read in keywords\n\n");//read in keywords pfile = fopen("a:\\newa.txt", "r"); if (!pfile) { perror("error"); } fread(f, sizeof(char), 50, pfile);//read in keywords char array (i = 0; i<50; i++) { if (f[i] == ',') { printf("\n"); } else { printf("%c", f[i]); } }//end loop printf("\n\n"); pause;//end reading in keywords //read in resume cls; resume = fopen("a:\\resume.txt", "r"); if (!resume) { perror("error"); } fread(r, sizeof(char), 50, resume);//read in resume char array (j = 0; j < 50; j++) { if (r[j] == ',') { printf("\n"); } else { printf("%c", r[j]); } }//end loop printf("\n\n"); pause; // end reading in resume
below i'm having break happen
//beginning search (c = 0; c < i; c++) { if (f[i] == r[c])//if keyword match resume add together counter { count++;//counter } }//end loop if (count == 0) printf("\n%s not nowadays in array.\n", search);//no matches else printf("\n%s nowadays %d times in array.\n\n", search, count);//keyword match , how many times found pause;//end search , output }
c arrays file linear-search
No comments:
Post a Comment