Hello,
I am trying to implement a simple function to return an array and I'm not having much luck. The program compiles but I am having trouble calling the array. Help.
Here is the function. I'm fairly new to programming and didn't even realize I needed to make this function a pointer until I found assistance on another thread. Then again it didn't work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
float *coriolus (constint xin)
{
constint xres=300; //Cross Process resolution
//const float dia=15.5;
constfloat od=15.6; //Plate OD
constfloat id=10.5; //Plate ID
constfloat pathwidth=(od - id)/2; //inches
constint pxwidth = floor(pathwidth*xres); //pixel width
constint columns = floor(pxwidth/xin);
float *centers = newfloat[columns];
for (int i=0; i < columns; i++){
centers[i]=(xin/2)+ (i * xin);
}
return centers;
}
I'm not done with this function but before continuing I'm just trying to get this part right. I would like to be able to call this function and get an array.
I have tried a few different ways of calling it including
float centers = coriolus(280);
and float centers[] = coriolus(280);
What am I missing?