C++ newbie question: can I use an array as an argument to this function?

Antst

New member
Joined
Jul 29, 2010
Messages
24
Reaction score
0
Points
1
Hi all:

I have a function defined as:

inline double myFunction( const long int z ) const
{ return C->myFunction[ C->z[ z ] ]; }

and called in main() as:

for ( long int i = 0; i < 10; i++ )
{
for ( long int j = 0; j < 20; j++ )
{
node->myFunction( myMatrix(i,vector[j] ) );
}
}

I want to use a matrix as the argument, but I keep getting a segmentation fault when I try to run the program. I don't understand why. Can anyone help based on the information I have given? I can change the argument, but not the function.

Thanks a lot for any help!
Hi Steve, I meant that is not possible for me to modify the function at all (for example, to accept a matrix as an argument). But I can change the way the function is set up. I may not have defined this question well enough for you guys to help!
 
const long int z

no, you can not use an array as an argument.

Just to double check, you can change the argument, but not the parameter?
 
There's no enough code there for us to figure out what's going on. We don't know what 'C' is or what type 'myMatrix' returns. We don't know how 'vector' is allocated. And so on.

It may help to add output lines all over the place. That way, at least you can see the last line of output and that will tell you which line of code is faulting.
 
Back
Top