I'm struggling a bit with pointers. I'm trying to pass information between functions, but am getting the following error: "request for member ‘score’ in something not a structure or union", and the same error with 'index' instead of score (and for all other members I'm doing this for that are not listed here).
Here is my struct:
typedef struct line_t {
char* buf;
int lineLength;
int wordCount;
int index;
double score;
} line_t;
This is my call to the function in main (with declaration):
line_t bestmatch[TOP_SCORING_MAX];
func3(&line, &bestmatch[TOP_SCORING_MAX]);
Here is my function:
line_t
func3(line_t line, line_t *bestmatchPtr[]) {
int i;
for (i=0; i< TOP_SCORING_MAX; i++) {
if (line.score != 0) {
if (i == 0) {
bestmatchPtr[0].score = line.score;
bestmatchPtr[0].index = line.index;
/*more code here: rest of func, closing of }, etc*/
return bestmatchPtr;
}
Essentially, I need to pass information about bestmatch between functions, while keeping it ordered (my function is attempting to order information and retain only a set amount of data). I was wondering how to fix this error? Let me know if I'm missing some information.