Question 14 of 148 points

Question 14 · 8 points

Function dispatch system

Implement evaluate.

typedef int (*operation_t)(int, int);

typedef struct {
    char symbol;
    operation_t function;
} operation_entry_t;

int evaluate(
    const operation_entry_t operations[],
    size_t count,
    char symbol,
    int left,
    int right,
    int *result
);

Search the dispatch table for symbol, call the corresponding function with left and right, store the returned value in *result, return non-zero when found, and return 0 when the operation does not exist. State how you handle invalid pointers or a matching entry whose function pointer is null.

Your response

Your answer

0 words