July 19th, 2013, 09:59 AM
Passing 2D array to and from a function in C++
I am new to C++ and having problem passing arguments between main and a function.
I would like to pass three values to a function, have it calculate a 2D matrix and return it back to main. I would like it to accept variable matrix size. I appreciate any help I can get on this. Here is my code:
using namespace std;
int k=0, j=0;
double Cb_n( double roll, double pitch, double heading, double **rr);
for (int k =0 ; k<3;k++)
for(int j =0 ;j <3;j++)
double Cb_n(double roll, double pitch, double heading,double **r)
// function for calculating the rotation body---->navigation Cbn
r = Ch*Cp;
r = Ch*Sp*Sr - Sh*Cr;
r = Ch*Sp*Cr + Sh*Sr;
r = Sh*Cp;
r = Sh*Sp*Sr + Ch*Cr;
r = Sh*Sp*Cr - Ch*Sr;
r = -Sp;
r = Cp*Sr;
r = Cp*Cr;
Last edited by qabdullah; July 19th, 2013 at 10:04 AM.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.