Information

Author(s) Mathieu Xhonneux & Maxime Mawait
Deadline No deadline
Submission limit No limitation
Category tags level1, s4

Tags

Sign in

[S4] Comparing functions

Pointers to functions can be used to handle functions in a dynamic fashion, and will be of great importance later in this course. It is hence important to grasp how they work.

In this exercise, you will code a function which receives pointers to two functions, to determine if these functions are equivalent. Two functions are considered to be equivalent if they always produce the same output for the same input.

The functions passed by pointers will be of the form uint8_t func(uint8_t n).


Compare functions

Write the function cmp_func (prototype and body), which receives two pointers to functions (described above), and returns an int, set to 1 if the functions are equivalent and 0 otherwise. Compare the two functions by testing their values for all possible uint8_t (i.e. from 0 to 255)