[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] OT: gsl_function with pointer
From: |
Martin Jansche |
Subject: |
Re: [Help-gsl] OT: gsl_function with pointer |
Date: |
Sat, 7 Oct 2006 15:43:43 -0400 |
On 10/7/06, Ivan Liu <address@hidden> wrote:
gsl_function * Integrand=0;
You've just initialized a pointer with NULL.
Integrand->function = &f;
Now you're dereferencing a NULL pointer.
it compiles successfully but fails on runtime.
As it should. (This is really a general C issue, not a GSL problem.)
You need to initialize integrand to point to allocated space
{gsl_function *integrand = malloc(sizeof(gsl_function));}, or
alternatively declare it as an automatic variable with a plain
gsl_function type (see
http://www.gnu.org/software/gsl/manual/html_node/Root-Finding-Examples.html#Root-Finding-Examples
for example).
-- mj
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Help-gsl] OT: gsl_function with pointer,
Martin Jansche <=