pow doesn't accept the second parameter to be a variable on gcc

Posted by Daziplqa on Stack Overflow See other posts from Stack Overflow or by Daziplqa
Published on 2010-05-19T14:11:54Z Indexed on 2010/05/24 3:00 UTC
Read the original article Hit count: 364

Filed under:
|
|
|

pow doesn't accept the second parameter to be a variable on gcc

The following code works fine on VC++10

// file test.cc
#include "stdafx.h"
#include <stdio.h>
#include <math.h>

int main(void)
{   
    double x = 10;
    int y = 20;
    printf("%f\n", pow(x, y));
    return 0;
}

But the following code doesn't not work on gcc:

// test.c
#include <stdio.h>
#include <math.h>

int main(void)
{   
    double x = 10;
    int y = 20;
    printf("%f\n", pow(x, y)); // error here, says no such function, however when pass the second argument in `pow` for the code runs by gcc, It works fine!
    return 0;
}

© Stack Overflow or respective owner

Related posts about c

    Related posts about math