Hi all,(adsbygoogle = window.adsbygoogle || []).push({});

I'm trying to play about with the GNU scientific library, which means learning how to use function pointers. When I run the code below, I can use function pointers to successfully evaluate two different functions. But I decided to try and look at the function addresses, and instead of the hexidecimal numbers I expected I got the integer "1" for both values. Can someone please explain to me what's going on?

Code:

#include <iostream>

#include <gsl/gsl_sf_bessel.h>

#include <gsl/gsl_math.h>

#include <gsl/gsl_integration.h>

int main()

{

double x = 5.0;

double y = gsl_sf_bessel_J0(x); //me using functions from the GNU scientific library

double z = gsl_sf_bessel_J1(x); //ditto

double t, u;

double (*fpt)(double) = &gsl_sf_bessel_J0;

double (*fpt2)(double) = &gsl_sf_bessel_J1;

t= (*fpt)(x);

u= (*fpt2)(x);

std::cout<< y <<"\n";

std::cout<< z <<"\n";

std::cout<< fpt << "\n";

std::cout<< fpt2 <<"\n";

std::cout<< &gsl_sf_bessel_J0 << "\n";

std::cout<< &gsl_sf_bessel_J1 << "\n";

std::cout<< &x <<"\n";

std::cout<< t <<"\n";

std::cout<< u << "\n";

return 0;

}

And here's the output:

-0.177597

-0.327579

1

1

1

1

0xbfb50420

-0.177597

-0.327579

Thanks.

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Function at memory address 1?(c++)

Loading...

Similar Threads for Function memory address |
---|

Surface plot for a 3D function |

Program that calculates the list of x and f(x) for a given function |

C/++/# Is Pass-by-Reference part of a Function Signature? |

Java Representation of two-dimensional arrays in the memory |

Fortran Fortran external functions vs subroutines |

**Physics Forums | Science Articles, Homework Help, Discussion**