here is the error I get when attempting to create a function that returns array data, what am I doing wrong?
Thanks - JZ
Building C:\outtput\test.obj.
C:\test.c(29): error #2168: Operands of + have incompatible types 'float (*)[10]' and 'float'.
C:\test.c(29): error #2144: Type error: pointer expected.
C:\test.c(29): error #2144: Type error: pointer expected.
*** Error code: 1 ***
Done.
#include <stdio.h>
#include <math.h>
float atmosphere_data(float alt, float air);
/*Atmosphere Table (US units)
alt sigma delta theta temp press dens a visc k_visc k_ratio
*/
float air_data[4][10] = {
/* -1 */ {1.0296, 1.0367, 1.0069, 522.2, 2193.8, 0.0024472, 1120.3, 0.376, 1.54E-4, 7.30},
/* 0 */ {1.0000, 1.0000, 1.0000, 518.7, 2116.2, 0.0023769, 1116.5, 0.374, 1.57E-4, 7.10},
/* 1 */ {0.9711, 0.9644, 0.9931, 515.1, 2040.9, 0.0023081, 1112.6, 0.372, 1.61E-4, 6.91},
/* 2 */ {0.0747, 0.0562, 0.7519, 390.0, 118.9, 0.0001777, 968.1, 0.297, 1.67E-3, 0.58}
};
void main()
{
float temp;
temp = atmosphere_data(0.0, 5.0);
printf("\n\n\t Here is the value for sealevel temperature: %f", temp);
printf("\n\n\t Press <Enter> key to exit... ");
while ((getchar()) != '\n'); printf("\n");
}
float atmosphere_data(float alt, float air)
{
return (air_data[alt+2][air]); // <== line with errors
}