Originally Posted by
matsp
You can't assign values to an array dynamically - you can initialize an array when it's created, but once it's been set, you need to use other methods (such as a loop that sets each element or copy from somewhere with memcpy()).
--
Mats
I'm still confuse your explain..
I get error on c program..
Code:
void cal_fft(x,y,l,mode)
float *x[],*y;
int l,mode;
{
int np,lmx,lo,lix,lm,li,j1,j2,nv2,npm1,i,j,k;
float scl,arg,c,s,t1,t2;
// --x;
// --y;
x[256] = { /*i got error error: expected expression before ‘{’ token
*/
455,
699,
831.5,
357.7, ..etc, because so many }:
y=0;
np=(int)pow(2.0,(float)l);
lmx=np;
scl=(float)(6.283185303/(float)np);
for(lo=1;lo<=l;++lo){
lix=lmx;
lmx=lmx/2.0;
arg=0.0;
for(lm=1;lm<=lmx;++lm){
c=cos(arg);
s=mode*sin(arg);
arg=arg+scl;
for (li=lix; lix<0 ? li>=np : li<=np; li+=lix){
j1=li-lix+lm;
j2=j1+lmx;
// t1=x[j1]-x[j2];
t2=y[j1]-y[j2];
// x[j1]=x[j1]+x[j2];
y[j1]=y[j1]+y[j2];
// x[j2]=c*t1+s*t2;
y[j2]=c*t2-s*t1;
}
}
scl=2.0*scl;
}
j=1;
nv2=(int)(np/2.0);
npm1=np-1;
for(i=1;i<=npm1;++i){
if(i>=j)
goto L30;
// t1=x[j];
t2=y[j];
// x[j]=x[i];
y[j]=y[i];
// x[i]=t1;
y[i]=t2;
L30:
k=nv2;
L40:
if(k>=j)
goto L50;
j-=k;
k=(int)(k/2.0);
goto L40;
L50:
j=j+k;
}
}
can you explain it why that error, with syntax