By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,484 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,484 IT Pros & Developers. It's quick & easy.

calling a function (passed as a pointer) causing segmentation fault

P: n/a
I get a segmentation fault in my program when calling a function
"TestFn" that has been passed as a pointer into another function.
The following excerpt should give enough information as to what I am
doing wrong...

typedef void TIdxMultiFunc (int i, std::vector<double> f);

void TestFn(int i, std::vector<double> f)
double t; // execution does not get this far
f[0] = t*t;
f[1] = t*t*t;

void TestSolve(std::vector<double> &a)
TIdxMultiFunc *ptr = &TestFn;
afn(y, ptr, 2);

void afn(std::vector<double> &y, TIdxMultiFunc *f, int n)
int i;
std::vector<double> bf;
bf.resize(ndata - 1);

for (i = 0; i < n; i++)
f(i, bf); // segmentation fault occurs here

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
PS. ndata should read n

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.