Question: My output is almost correct but its wrong. #include search.h #include / / #include / / typedef struct { int sought _ index; int
My output is almost correct but its wrong.
#include "search.h
#include
#include
typedef struct
int soughtindex;
int foundvalue;
int foundindex;
Match;
int readsoughtvaluesFILE file int soughtvalues
int value, count ;
while fscanffiled &value && value && count MAXSOUGHTVALUES
soughtvaluescount value;
return count;
void processsearchspaceFILE file int soughtvalues int soughtcount, FILE outputfile
int searchspace;
int value, searchsize ;
while fscanffiled &value && value
searchspacesearchsize value;
fprintfoutputfile, "Searching file for matches for d values.
soughtcount;
fprintfoutputfile, "Searched at Searching Found at
;
fprintfoutputfile,
;
Match matches mallocsearchsize sizeofMatch;
if matches
fprintfstderr "Memory allocation failed
;
exitEXITFAILURE;
int matchcount ;
for int i ; i soughtcount; i
for int j ; j searchsize; j
if searchspacej soughtvaluesi
matchesmatchcountsoughtindex i;
matchesmatchcountfoundvalue soughtvaluesi;
matchesmatchcountfoundindex j;
matchcount;
for int i ; i matchcount; i
fprintfoutputfile, d d d
matchesisoughtindex, matchesifoundvalue, matchesifoundindex;
fprintfoutputfile, "Number of items searched through in list: d
searchsize;
freematches;
Wrong: Searching file for matches for values.
Searched at Searching Found at
Number of items searched through in list:
Correct: Searching file for matches for values.
Searched at Searching Found at
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
