typedefdouble (*Matrix)[imax][jmax];
Matrix xboundary(){
Matrix xx;
double x[imax][jmax];
int i;
x[0][jmax-1]=xmin;
x[0][0]=xmin;
for (i=1;i<imax;i++){
x[i][jmax-1]=x[i-1][jmax-1]+((xmax-xmin)/(imax-1));
}
for (i=1;i<11;i++){
x[i][0]=x[i-1][0]+(0-xmin/(11-1));
if ((x[i][0]) > -0.0001 )
x[i][0]=0;
}
for (i=11;i<31;i++){
x[i][0]=x[i-1][0] + 0.05;
}
for (i=31;i<41;i++){
x[i][0]=x[i-1][0]+((xmax-1)/(41-31));
}
xx=&x; // I know this is completely wrong but would like to return 'x'
return xx;
}
All I want to do is be able to Return "x" in some way. I know I m doing it completely wrong but any kind of help would be appreciated. Thanks
You could pass the 2d array in as a parameter. Or you could define a Matrix class. In C++11, the move semantics will allow you to return such an object with very little overhead.