0

I am writing a c program for a virtual computer. The problem I am having right now is that when I try to compile, I get an error that says "undefined reference to 'pow' I'm not sure how to change it correctly.

void memAssign(signed int *mem, char line[SIZE],signed int *memPos){
    signed int *count= &mem[73];
    signed int *length= &mem[74];
    *length = strlen(line)-1;
    *count=1;
    if(toDigit(line[*length-1])<0 || toDigit(line[*length-1])>9){
        printf("Wrong command form.\n");
        return;
    }
    while(line[*length - *count] != ' '){
        mem[*memPos] += (toDigit(line[*length - *count]) * (int)pow(10, *count - 1));
        *count += 1;
    }
    count = NULL;
    length = NULL;
}

1 Answers1

4

While using the math library functions you have to include the header file #include<math.h>. And then while compiling you have to link that.

 cc filename.c -lm 
Karthikeyan.R.S
  • 3,991
  • 1
  • 19
  • 31