www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/10/08:10:11

From: Bill Glenn <bglenn AT zip DOT com DOT au>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help needed with a program I am writing
Date: Fri, 10 Dec 1999 22:44:10 +1100
Organization: Zip World/Pacific Internet
Lines: 50
Message-ID: <3850E78A.F62B1D2E@zip.com.au>
References: <dPE24.416$wM4 DOT 28044 AT news-west DOT eli DOT net>
NNTP-Posting-Host: whiz10.zip.com.au
Mime-Version: 1.0
X-Trace: the-fly.zip.com.au 944826027 17720 61.8.19.186 (10 Dec 1999 11:40:27 GMT)
X-Complaints-To: news AT zipworld DOT com DOT au
NNTP-Posting-Date: 10 Dec 1999 11:40:27 GMT
X-Mailer: Mozilla 4.51 [en] (Win95; I)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019