Mail Archives: djgpp/1999/12/10/08:10:11
Maybe soemthing else is messing things up
try this
#include <math.h>
int main ( int argc, char *argv[] )
{
int a;
float cos_table[360], sin_table[360];
float pi = 3.14159;
for(a = 0; a < 360 ; a++)
{
cos_table[a]=cos((float)a/180 * pi);
sin_table[a]=sin((float)a/180 * pi);
}
for(a = 0; a < 360 ; a+=45)
{
printf("cos(%d) = %.2f sin(%d) = %.2f\n",a,cos_table[a],a,sin_table[a]);
}
return(0);
}
P K wrote:
> Ok,
>
> I am a newbie to DJGPP and I dont understand what this error means or how to
> fix it:
> invalid types `float[360][float]` for array subscript
>
> I get that 4 times when I try to compile the program. The piece of code I
> think it is refering to is when I try to make my sine and cosine tables.
> This is the code I have for them:
> float cos_table[360], sin_table[360];
> float pi = 3.14159;
>
> for(a = 0; a < 360 ; a++)
> {
> cos_table[a]=cos((float)a/180 * pi);
> sin_table[a]=sin((float)a/180 * pi);
> }
>
> Ive tried taking the float decleration for the a variable in both lines but
> still get the error, I also tried making the array types doubles but it
> didnt work either. In case your wondering what the program is designed to do
> its a primitive raycasting engine Im making for a project due next week. If
> you have any suggestions on how to fix this please let me know by either
> post or e-mail. Any and all help is appreciated and thank you in advance
- Raw text -