Hi everyone,
I ran into problems with the pow() function in my main program so I isolated the problem in another c file to test out but I am still not sure what could be wrong.
Code:
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char **argv) {
int i = atoi(*(++argv));
int d = atoi(*(++argv));
printf("%d^%d=%d\n",i,d,pow(i,d));
// the output of this is i^d=i, not sure why
}
As noted in the comments but the pow() function is not working correctly and I am already using the -lm option because I am using gcc.
I get the above output of i^d=i for any combination of i and d. Any idea what could be wrong?