Multiple choice

void (*signal(int sig, void (*handler) (int))) (int); Which of the following definitions of sighandler_t allows the above declaration to be rewritten as follows? sighandler_t signal (int sig, sighandler_t handler);

  1. typedef void (*sighandler_t) (int);

  2. typedef sighandler_t void (*) (int);

  3. typedef void *sighandler_t (int);

  4. #define sighandler_t(x) void (*x) (int)

  5. #define sighandler_t void (*) (int)

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The declaration means: signal is a function returning 'pointer to function taking int returning void'. To simplify, we typedef the return type: typedef void (*sighandler_t)(int). Then: sighandler_t signal(int sig, sighandler_t handler). This matches option A exactly.