Function pointer pointing to built in function in C

Viewed 158

I'm trying to set a function pointer to point to the pow function. Here's my code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
    double (*func)(double, double) = pow;
  return 0;
}

But the program doesn't compile. I get this error:

$ gcc test.c -o test

/tmp/ccD6Pmmn.o: In function `main':
test.c:(.text+0x8): undefined reference to `pow'
collect2: error: ld returned 1 exit status

I'm using Ubuntu 15.10.

Anyone knows what's wrong with my code?

Thanks

1 Answers
Related